简体   繁体   English

exec无法在php脚本中工作(WAMP服务器)

[英]exec not working in php script ( WAMP Server )

I am using WAMP server on my system to execute php scripts. 我在我的系统上使用WAMP服务器来执行php脚本。

I want to execute a script test.php from my main script main.php . 我想从我的主脚本main.php执行脚本test.php

For that I am using exec function like this exec('php test.php'); 为此,我使用exec函数,如这个exec('php test.php'); . In test.php I have given one echo statement. test.php我给出了一个echo语句。

But when I run my main.php script from the browser I am not able to see output of test.php script. 但是当我从浏览器运行我的main.php脚本时,我无法看到test.php脚本的输出。

What am I doing wrong ? 我究竟做错了什么 ? please suggest. 请建议。

You have to give the proper path of php.exe 你必须给出正确的php.exe路径

exec("c:\wamp\<where ever you exe is>/php.exe test.php");

so it has to be a proper path 所以它必须是一条正确的道路

use this command 使用此命令

echo exec('php test.php', $output);  //this will print your echo statement.
print_r($output);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM