473,836 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2646
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_********@yaho o.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_********@yaho o.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
Electrum
1 New Member
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
4971
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
3586
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 stdin pipe, it seems that if I give it some error nous expression, the pipe would return the exception data, though nothing else comes through. A friend of mine also tried this using win32api on delphi, and got the same result.
20
2462
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 just run scriptname.py (NOT python -i scriptname.py) and inside of scriptname.py I decide that I want to fall back to the interactive prompt? I've searched and so far the only thing I've come up with is to use pdb, but
2
7816
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 finding it a bit cumbersome. It works, but if I switch from the interactive window to the plot window and back, the plot window gets trashed.
3
1702
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 command lines be executed automatically: Python 2.3.4 (#2, Aug 19 2004, 15:49:40) on linux2 Type "help", "copyright", "credits" or "license" for more information.
1
1873
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 s=='no': print "Well my boss has 2" Now i have also been looking at Tkinter if we take the basic "hello, world"
13
3363
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. Please comment and correct me if I am wrong In both languages, you can start up the interactive interpreter ('python' and 'irb'), load source files and do stuff, like create objects and call their methods. When you want to change something, you can...
2
2187
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}" python test.py -- I get an ImportError:
3
1888
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; there is an IPShellEmbed method which returns something you can call. But how could one do the same for the stock python interactive shell? To take this out of the realm of debugging. What you want to do is to write a python program that goes...
8
5589
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 interactive Python shell on Windows that supports: - easy copy-pasting to/from an editor? (as opposed to the cumbersome "mark", "copy" and then "paste" sequence that any terminal on Windows
0
9826
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10860
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10604
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5831
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.