I have tried to execute simple php code in the php interpreter.
When I executed the command php -a
I getting the message
Interactive mode enabled
Without any place for php input.
But I can execute a php code through the command php -r
.
for example:
php -r "echo 'Hello stackoverflow!';"
Hello stackoverflow!
There seems to be a compilation / linkage error between your PHP and libreadline. This is documented in PHP Bug #48759.
make clean
before your final build?php -m
list readline as enabled feature? (Is PHP built with option--with-readline
)To check if you have readline module installed, type:
php -m | grep readline
If nothing displayed, install readline module:
sudo apt-get install php5-readline
After module installation you can recheck it's presence with previous command, than enter interactive mode with:
php -a
After I got tired of compiling it on each machine I used PHPSH (as mentioned by joey-adams)
It is much better then php -a (syntax highlighting and autocompletion)
Install python phpsh
look at install-php5-with-readline-support-on-debian-wheezy
This is what you should see:
Install this:
then try use:
type
php -m
and make sure you have the readline module. If you don't you won't be able to use it.http://www.php.net/manual/en/features.commandline.interactive.php