I have a very simple test.php file:
<?php
echo 'Hello World';
Then I run it from Mac Shell: php test.php
But it does not echo anything. Looks like it's blocked for some reason, like this:
If I use invalid syntax in the file, for example:
<?php
invalid syntax
Then I can see the error output:
PHP Parse error: syntax error, unexpected 'syntax' (T_STRING) in .../test.php on line 3
Parse error: syntax error, unexpected 'syntax' (T_STRING) in .../test.php on line 3
What's wrong with it?
FYI:
php -i
can print php.ini info echo 'test'
can print 'test' Turning my comments into an answer as requested :
Here are two possible reasons why php command doesn't work as expected:
Maybe it is aliased (try which php
or prepend a backslash (\\) to the command)
You mentioned that you had a directory named php on your working directory. Well, zsh has a feature called AUTO_CD that may have interfered in this case. Basically AUTO_CD allows you to switch directories without typing cd and can be disabled by adding unsetopt autocd
to zshrc file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.