PHP will not run from command line

General Tech Bugs & Fixes 2 years ago

0 3 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (3)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

When trying to run a PHP script from inside Terminal, the script is just echoed to stdout. This happens if the script is executed directly (first line #!/usr/bin/php) called as an argument (/usr/bin/php ./test.php), or if the php command(s) is input interactively.

What could be the problem?

Computer is El Capitan Server, 10.11.6; and, no extra MAMP/Apache/PHP has been installed. On a non-server El Capitan machine, things work as expected; so, I'm stumped...

Adding output of ls command:

sh-3.2# ls -lFa /usr/bin/php
-rwxr-xr-x  1 root  wheel  10577264 Jul  9 11:51 /usr/bin/php*
sh-3.2# 

Adding more output:

sh-3.2# ls -lFa /var/root/test.php
-rwxr-xr-x  1 root  wheel  17 Nov 21 16:48 /var/root/test.php*
sh-3.2# f="https://forum.tuteehub.com/tag/cat">cat /var/root/test.php
f="https://forum.tuteehub.com/tag/phpinfo">phpinfo();
?>
sh-3.2# /usr/bin/php /var/root/test.php
f="https://forum.tuteehub.com/tag/phpinfo">phpinfo();
?>
sh-3.2# od -c /var/root/test.php
0000000    <   ?  \n   p   h   p   i   n   f   o   (   )   ;  \n   ?   >
0000020   \n                                                            
0000021
sh-3.2# od -x /var/root/test.php
0000000      3f3c    700a    7068    6e69    6f66    2928    0a3b    3e3f
0000020      000a                                                        
0000021
sh-3.2# 
profilepic.png
manpreet 2 years ago

Use the long tag like

tag/php">php
tag/php">phpinfo();

in test.tag/php">php instead of your somehow malformed test.tag/php">php and it should work.


0 views   0 shares

profilepic.png
manpreet 2 years ago

Use the long tag like

tag/php">php
tag/php">phpinfo();

in test.tag/php">php instead of your somehow malformed test.tag/php">php and it should work.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.