Monday, October 29, 2007

PHP interactive shell


A feature of PHP I use in my day to day life as developer — but that lots of PHP developers seems to ignore — is the Interactive shell of PHP:

$ php -a

Like with Python, Ruby, Perl and many others, PHP benefits also of this feature that lets you try copy/pasted code, try some functions/algorithms before integrating them directly into a code or maybe just trying to find some weird behavior of PHP itself.

Like a real shell, the PHP interactive shell comes with:

  • Tab completion
  • History
  • Integration of all the interesting shortcuts to edit the current line (PG+Up/Down, ALT+Backspace, ALT+Left/Right, CTRL+D,...)
  • etc.

Next time you will:

  1. Create a PHP file into your DocumentRoot
  2. Open it with your favorite editor
  3. Fire up your browser to reach your newly created file
  4. Show the source code of the generated page

Maybe this day will you find command line easier :)

Want to view a demo of all this ? Sure:

1 comment:

DragonBe said...

Hey Patrick,


I enjoyed this interactive demo, but maybe a little narration would have added an extra charm to it.

Anyway, I enjoyed the topic and love to read more about it.

Michelangelo "DragonBe" van Dam