Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Interactive PHP like Python
April 16, 2006, 7:16 pm
rate this thread
well exept you have to keep putting <?php code here ; bla blah code ;
Couple of problems with this.
1) Exits php when you make an error.
2) When you type a command; it displays the result but does not do an
Would be nice if it opened up in a window, and you just type and press
enter and see the result on the next line.
Allow you to move up to a previous command and edit and press Enter.
This would allow people to test commands and learn. You could even load
personal functions from a php file to do some testing
Anyone know of a nice php interactive shell like Python's?
Re: Interactive PHP like Python
Why not build this yourself? This will only take you 10-30 minutes, much
less then searching for an interactive shell. All you need is a web
server that runs php.
Make a php script that outputs a form with a textarea where you can
enter some php code. The form targets the same php script. The script
outputs the form once again with the same php code that was entered.
Then, below the form, it outputs a DIV with fixed sizes and a scroll bar
(style=). After outputting the <DIV styl= > tag, pass the code from the
textarea passed to php's eval function. This will run the code. Anything
that is printed from the eval'd php code will appear inside the DIV.
Then print the end of the DIV and the end of the page. Or before the end
of the page add another scrollable DIV with in between <PRE> tags
print_r the eval result.
If you want a new line to start after printing, add a simple function
and call it from the eval'd php code.
WARNING: DO *NOT* put such a script on your website or any publically
accessable web server directory as it would allow anyone to execute any
php code on your server, allowing the reading of all its publically
readable files, and probably hack you server.