我有一个 php 脚本,它计算的东西非常长。
它是从 js 文件中调用的,除了从 js 文件中调用它之外,我还想从另一个 php 文件中调用它。
该文件称为 strategy.server.php,它是这样构建的
<?php
include_once("../config.php");
include_once("../class/simulator.class.php");
$simulator = new Simulator();
$SPOT = $_GET["strikePrice"];
$INTEREST = $_GET["interestRate"] / 100;
$VOLATILITY = $_GET["volatility"] / 100;
$REMAININGDAYS = $_GET["remainingDays"] / 365;
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/json; charset=utf-8");
if(!empty($_GET['mycase']))
{
switch($_GET['mycase'])
////calculations...
$data['totalMargin'];
echo json_encode($data);
我正在尝试使用相同的文件来计算不同的参数(在循环中)。
所以我考虑使用一个包含并像这样发布参数:
$params = "some params...";
$params .= "strikePrice=".$data["strikePrice"].
"&volatility=".$data["volatility"].
"&remainingDays=".$data["remainingDays"].
"&interestRate=".$data["interestRate"].
"&commission="."7".//$data["commission"].
"&profitDays="."7";//$data["profitDays"];
include("server/strategy.server.php?" .$params);
json_decode($data);
echo $data['totalMargin'];
但它给出了一个错误:
Warning: include(server/strategy.server.php?mycase=1&rangeMin=0&rangeMax=0&strikePrice=1078&volatility=24&remainingDays=51&interestRate=2.5&commission=7&profitDays=7)
[function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\s-maof-vb\PRO\functions_alarms.php on line 86
如果我包含带有参数的文件,它会加载(但没有参数..)