I'm using Ubuntu 12.04 64 bit and I want to use the PHP interactive shell:
php -a
But it doesn't seem to work very well, a lot of syntax is incorrectly interpreted.
When I run php -a
it displays:
interactive mode enabled
And just a cursor blinking.
I'm using: PHP 5.4.13-2~precise+1 (cli) (built: Mar 21 2013 12:17:18)
How do I use the PHP interactive shell?
How to use the PHP interactive shell
phpsh was made by facebook. To install it see this: http://www.phpsh.org/
Installation directions:
Pull the repository, cd into it and install:
Run it:
Walkthrough:
Printing strings:
Do some math:
Print some builtin variables:
Print contents of that array:
Get a key of that array:
Addition of a different kind:
Print the previous:
Store a variable:
An equation can be held open through newlines until it completes:
Define our own arrays:
Get the type of a variable:
For great justice, loops:
Get yerself some info:
Explode parses the string on space into an array, print_r pretty prints it:
Foreach structure can be extended onto following lines.
Block comments are ignored:
Read from a file:
No, no time:
Pure sweet truth:
Make an array, search for an item in it.
You want more??? There is enough to fill a lifetime, godspeed: http://php.about.com/od/advancedphp/
Try installing http://www.phpsh.org/ it is probably the easiest solution.
Steps: (assuming dependency's installed)
git clone https://github.com/facebook/phpsh
cd phpsh
sudo python setup.py install
phpsh
This is what you'll get when the
php5-readline
package is not installed. Assuming that's your problem you can fix it by running this command:How about PsySH ?
A litle example :