I know that you can run php files from terminal with linux running PHP... I.e. "php script.php" ... But is there any program that allows you to directly input php into the terminal (through any intermediary program) and output the results? I.e. In terminal, testing php globals like getinfo(), etc..? Any help would be great, I'd like to test functions and commands through a sort of run-time terminal. Thanks!
3 Answers
php -a (as of PHP 5.1) should do what you want.
http://php.net/manual/en/features.commandline.interactive.php
3 Comments
CrandellWS
If you type 'php -a' and get a response of 'Interactive Shell' followed by a 'php>' prompt, you have interactive shell available (PHP was compiled with readline support). If instead you get a response of 'Interactive mode enabled', you DO NOT have interactive shell available... link Without the shell you can try the suggested method here
Edson Horacio Junior
@CrandellWS Thanks very much for the tip!!! I got that
Interactive mode enabled and didn't know about that.Mona Jalal
what about a .php file?\
php -r 'phpinfo();'
worked for me on OSX.
1 Comment
CrandellWS
A better way would be to use a shell see here If you type 'php -a' and get a response of 'Interactive Shell' followed by a 'php>' prompt, you have interactive shell available (PHP was compiled with readline support). If instead you get a response of 'Interactive mode enabled', you DO NOT have interactive shell available and this would be why you would use this answer.
1 Comment
Jeremy Roman
This is more like an SSH client written in PHP than a tool for debugging PHP.