Reputation: 4509
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 infoecho 'test'
can print 'test'Upvotes: 1
Views: 1913
Reputation: 20424
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.
Upvotes: 1