1

I am using WAMP server on my system to execute php scripts.

I want to execute a script test.php from my main script main.php.

For that I am using exec function like this exec('php test.php');. In test.php I have given one echo statement.

But when I run my main.php script from the browser I am not able to see output of test.php script.

What am I doing wrong ? please suggest.

1
  • You need to give the full path where the php installed in your wamp server. Commented Feb 4, 2013 at 5:12

2 Answers 2

2

You have to give the proper path of php.exe

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

so it has to be a proper path

Sign up to request clarification or add additional context in comments.

1 Comment

@rohitarora....yeah it worked..thanks.. Can I set this path in the environment variable. and use only php here ?
1

use this command

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

1 Comment

@Mayank the second parameter stores the output of the command in $output variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.