[SOLVED] PHP Interactive Mode

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

[SOLVED] PHP Interactive Mode

Post 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?
Last edited by Mirge on Mon Sep 21, 2009 4:30 pm, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP Interactive Mode

Post 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.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: PHP Interactive Mode

Post 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 :).
Post Reply