PHP CMD error : Could not open input file [duplicate] - php

This question already has answers here:
Running PHP script from the command line
(3 answers)
Closed 8 years ago.
I want to run php files using command prompt.For this I set the system variable's path variable(C:\wamp\bin\php\php5.4.16).
After set the path I restart the system and I m trying to run the php file.
I typed
php test.php
But its says
Could not open input file

Run:
pear
it will set %PHP_PEAR_PHP_BIN% for you.

Related

How can I run php commands directly in console? [duplicate]

This question already has answers here:
How can I execute PHP code from the command line?
(6 answers)
Closed 2 years ago.
When I run PHP in my console (any cli application) and I sending a command like below, it not returned anything!
echo 'Hi!';
Is there any way to run PHP commands directly in console or just we can run a .php file?
Note: My environment variables and path is OK.
You may use PHP's interactive shell
php -a
echo 'Hi!';

Can not Execute PHP code in Browser [duplicate]

This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
in the following 2 images i just want to run a very simple php code (file:///C:/wamp/www/test/1.php)
using a running WampServer Version 3.0.6 64bit then the result when i try to execute this file in browser still the same code as i written
php code
my browser
Note that you are opening a file.In URL its opening file://... but when you want the localhost server to process the file, you need to open your file as http://localhost/test/1.php.
Hope it helps. All the best!
Put this file into WWW folder of a WAMP-SERVER
then try localhost/yourFileName.php

How to specify PHP static function argument from terminal [duplicate]

This question already has answers here:
Pass a variable to a PHP script running from the command line
(14 answers)
Closed 6 years ago.
I have a script, which executes by Example::main("file.csv");.
I want to run the script from the terminal, but how can I achieve, so I don't define the argument in the script, but in the terminal, like php Example.php file.csv?
Thanks!
Example::main($argv[1]); is the solution.

php exec in background not working [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Call another PHP script and return control to user before the other script completes
Hello,
I'm executing this command in php:
exec('php /path/to/script.php one_argument_passed &");
But it's not executing it in the background. Is there a setting or something in php I need to do to make this work?
Maybe you have a permissions problem.

Python and executing php files? [duplicate]

This question already has an answer here:
Closed 12 years ago.
Possible Duplicate:
Start local PHP script w/ local Python script
How do you execute a php file and then view the output of it?
os.system("php ./index.php")
Does not work only returns 0
What you need is the os.popen function. It runs the command and returns the stdout pipe for that commands output. You can also capture the stdin, stderr by using os.popen2, popen3
import os
outp = os.popen('php ./index.php')
text = outp.read() # this will block until php finishes
# and returns with all output in text
print text
If you're working under Windows, you can use os.startfile().

Categories