Page 1 of 1

[SOLVED] PHP Interactive Mode

Posted: Mon Sep 21, 2009 12:10 pm
by Mirge
I've been using PHP since PHP3, but somehow I've never really heard of the interactive mode flag before, and when I tried to use it... it doesn't work, sort of.

Anyway... I use: php -a

Then I type in some php code, ie: <?php print "Hi"; ?>

I have to press ctrl+d, enter, ctrl+d (Linux).. or ctrl+z, enter, ctrl+z (Windows)....... then it exits. I see sometimes people using something like:

php > here is where you'd enter code.
php > and here
php > and here..

Mine don't show any sort of "console" prompt I guess you could say. Any idea why not and how I can get it?

Re: PHP Interactive Mode

Posted: Mon Sep 21, 2009 1:59 pm
by requinix
From the manual,
Runs PHP interactively. If you compile PHP with the Readline extension (which is not available on Windows), you'll have a nice shell, including a completion feature (e.g. you can start typing a variable name, hit the TAB key and PHP completes its name) and a typing history that can be accessed using the arrow keys. The history is saved in the ~/.php_history file.
So on Windows, `php` and `php -a` are basically the same. On Unix you have to install that one extension to get the fancy features.

Re: PHP Interactive Mode

Posted: Mon Sep 21, 2009 2:48 pm
by Mirge
Ahh thanks. I've been searching around for a while & never ran across that. I've lived without it for years, I'll be okay without it :).