[英]calling a php function with exec()
I am trying to use exec() to run and pass parameters to a php function named new_array() in array_module.php and expect an array return but having no luck. 我试图使用exec()来运行并将参数传递给array_module.php中名为new_array()的php函数,并期望数组返回但没有运气。 using the format:
使用格式:
$cmd = exec('cd "c:/wamp/www/test_array" && php array_module.php "'.$input['first'].'"
"'.$input['second'].'" ');
Any help is appreciated 任何帮助表示赞赏
Don't make a call through the command line to another file. 不要通过命令行调用另一个文件。 Import the other file so its functions become available and simply call the function directly:
导入另一个文件,使其功能可用,然后直接直接调用该函数:
require_once 'c:/wamp/www/test_array/array_module.php';
$result = new_array($input['first'], $input['second']);
This assumes that array_module.php
is written in a sane way so it can be imported elsewhere of course, eg: 假定
array_module.php
是用一种合理的方式编写的,因此可以将其导入其他地方,例如:
<?php
function new_array($one, $two) {
...
return $result;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.