Reputation: 6207
the site Im developing has only this:
echo php_sapi_name();
now from CMD, I run this:
php -d display_errors=1 -r "echo file_get_contents('http://site');"
it returns apache2handler
instead of cli
. Why?
Upvotes: 1
Views: 37
Reputation: 3861
When you run the following command:
php -d display_errors=1 -r "echo file_get_contents('http://site');"
You're actually loading the file from Apache (using the HTTP protocol). That's why you get apache2handler
instead of cli
. The PHP script is running under Apache. This is the same result you get when accessing http://site
via some browser. In this case, your PHP client is acting as your browser.
If you need to run your script from PHP client, you have to call it this way, from command line:
php file.php
You need to have access to the file from your file system. Using the above command, I'm assuming you are in the same directory as the script is.
Upvotes: 1