473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Interactive PHP like Python

I know you can start php -a and go into interactive mode. This works
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
automatic CR/LF

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?

Thanks

Apr 16 '06 #1
4 2613
Hi J,

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
printLn($aValue) {
print $aValue;
print "<BR>\n";
}
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.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

j_********@yahoo.com wrote:
I know you can start php -a and go into interactive mode. This works
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
automatic CR/LF

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?

Thanks

Apr 16 '06 #2
I was hoping not to reinvent the wheel. Maybe someone else knows of a
module that does this. But I can see where it wouldnt be hard to
develop.

Henk Verhoeven wrote:
Hi J,

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
printLn($aValue) {
print $aValue;
print "<BR>\n";
}
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.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

j_********@yahoo.com wrote:
I know you can start php -a and go into interactive mode. This works
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
automatic CR/LF

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?

Thanks


Apr 17 '06 #3
I wrote such a script:

http://david.acz.org/phpa/
May 12 '06 #4
I wrote an interactive PHP shell, modeled after the Python shell:

http://david.acz.org/phpa/

May 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: leroybt.rm | last post by:
I don't understand why this does not work: <FILE1> test1.py #Import Packages import string # data=0 data=data+1
6
by: Avi Berkovich | last post by:
Hello, I was unable to use popen2.popen4 to grab python.exe's (2.3) output, for starts, it doesn't show the version information at the beginning and won't return anything when writing to the...
20
by: Joe | last post by:
When you run "python -i scriptname.py" after the script completes you left at the interactive command prompt. Is there a way to have this occur from a running program? In other words can I...
2
by: Charles Krug | last post by:
List: I'm trying to us pylab to see what I'm doing with some DSP algorithms, in case my posts about convolution and ffts weren't giving it away. I've been using pylab's plot function, but I'm...
3
by: qwweeeit | last post by:
Hi all, is it possible to enter an interactive session and automatically do some initialization? I explain better: I want that when I start interactive Python on a console (I use Linux) two...
1
by: cm012b5105 | last post by:
Hello i am fairly new to python, I have written an interactive programme a small example of it is here. s = raw_input ("Do you have any children? ") if s== 'yes': print "Thats great" elif...
13
by: dmh2000 | last post by:
I am experimenting with the interactive interpreter environments of Python and Ruby and I ran into what seems to be a fundamental difference. However I may be doing something wrong in Python....
2
by: Adam Blinkinsop | last post by:
I'm writing a set of modules to monitor remote system services, and I'm having a problem running my test scripts. When I pass the scripts into python, like so: -- $ PYTHONPATH="${TARGET_DIR}"...
3
by: R. Bernstein | last post by:
The next release of pydb will have the ability to go into ipython from inside the debugger. Sort of like how in ruby-debug you can go into irb :-) For ipython, this can be done pretty simply;...
8
by: james.kirin39 | last post by:
Hi everyone, After having used Python on Linux for some time, I now have to do Python coding on Windows. I am big fan of the interactive Python shell to test, eg, regexps. Is there an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.