How to use the PHP interactive shell

mohur picture mohur · Apr 2, 2013 · Viewed 10.2k times · Source

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?

Answer

mmalone picture mmalone · Jul 22, 2016

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:

sudo apt-get install php5-readline