I'm interested in implementing a command-line PHP app that takes input
line-by-line (for example, using Readline) and executes commands as
they are entered. It would need to know the difference between this:
echo "hello world";
which should be eval()ed after the first line, and this:
for ($i=0; $i < 10; $i==) {
echo $i;
}
which can't be executed until the block is closed.
I suppose I could try calling eval() and catching errors until it
works, but then how to distinguish between a data-entry error (e.g.,
"ecoh $i") and an error indicating that you're in the middle of a
possibly valid block?
Thanks for your help,
G 6 1967
On 29 Nov 2004 18:54:02 -0800, gn******@gmail. com (George Nachman)
wrote: I'm interested in implementing a command-line PHP app that takes input line-by-line (for example, using Readline) and executes commands as they are entered. It would need to know the difference between this:
echo "hello world";
which should be eval()ed after the first line, and this:
for ($i=0; $i < 10; $i==) { echo $i; }
which can't be executed until the block is closed.
I suppose I could try calling eval() and catching errors until it works, but then how to distinguish between a data-entry error (e.g., "ecoh $i") and an error indicating that you're in the middle of a possibly valid block?
why not just typ php from the command line? You get a prompt. enter
the stuff. It works.
--
gburnore@databa six dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
=============== =============== =============== =============== ===============
Want one? GET one! http://signup.databasix.com
=============== =============== =============== =============== ===============
"George Nachman" <gn******@gmail .com> wrote in message
news:e5******** *************** **@posting.goog le.com... I'm interested in implementing a command-line PHP app that takes input line-by-line (for example, using Readline) and executes commands as they are entered. It would need to know the difference between this:
echo "hello world";
which should be eval()ed after the first line, and this:
for ($i=0; $i < 10; $i==) { echo $i; }
which can't be executed until the block is closed.
I suppose I could try calling eval() and catching errors until it works, but then how to distinguish between a data-entry error (e.g., "ecoh $i") and an error indicating that you're in the middle of a possibly valid block?
Thanks for your help, G
Prepend the PHP code block with a simple assignment. If there're no syntax
error, then the assignment would be made. Otherwise the the assignment is
not made. Use the @ operator to suppress the parse error message.
$statement = '$apple = $orange;'; // whatever
$parse_error = true;
@eval("\$parse_ error = false; $statement");
if($parse_error ) {
....
}
else {
....
}
Set a custom error handler with set_error_handl er() to handle non-syntax
errors in the code.
Chung,
I'm not sure I understand how this could distinguish between a syntax
error and a well-intentioned but incomplete script?
Also, thanks for your incisive comments there Gary. Real helpful. Prepend the PHP code block with a simple assignment. If there're no syntax error, then the assignment would be made. Otherwise the the assignment is not made. Use the @ operator to suppress the parse error message.
$statement = '$apple = $orange;'; // whatever
$parse_error = true; @eval("\$parse_ error = false; $statement"); if($parse_error ) { ... } else { ... }
Set a custom error handler with set_error_handl er() to handle non-syntax errors in the code.
"George Nachman" <gn******@gmail .com> wrote in message
news:e5******** *************** ***@posting.goo gle.com... Chung,
I'm not sure I understand how this could distinguish between a syntax error and a well-intentioned but incomplete script?
Well, you're trying to do the impossible then. PHP can't read mind and can't
see into the future. How can you tell whether, say, the absence of a curly
bracket is imcompleteness or a mistake? What I have give you is a mean to
detect syntax error in the code.
You're describing an interprative PHP environment. Essentiall you would
run the script upon completion. Which is basically what you can do now,
an integrated PHP environment with an external debugger would give you
most of what you want and it's all readily available.
D
"Chung Leong" <ch***********@ hotmail.com> wrote in message news:<QJ******* *************@c omcast.com>... "George Nachman" <gn******@gmail .com> wrote in message news:e5******** *************** ***@posting.goo gle.com... Chung,
I'm not sure I understand how this could distinguish between a syntax error and a well-intentioned but incomplete script?
Well, you're trying to do the impossible then. PHP can't read mind and can't see into the future. How can you tell whether, say, the absence of a curly bracket is imcompleteness or a mistake? What I have give you is a mean to detect syntax error in the code.
I should have been more specific. What I need to know, specifically,
is if the braces, quotation marks, etc. are balanced. The Tcl language
provides a C API to do this--Tcl_CommandComp lete
( http://www.tcl.tk/man/tcl8.2.3/TclLi...mplt.htm)--and I'm looking
for an analogue in PHP. Hopefully no mind-reading will be needed :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave Reed |
last post by:
I seem to remeber reading somewhere there was a statement you could
put in your python program to stop its execution and start the
interactive interpreter at that point (and then you could change the
value of some variables and continue executing). Am I having delusions
or is there a way to do this?
Thanks,
Dave
|
by: Miki Tebeka |
last post by:
Hello All,
If there a way a script can tell Python to enter interactive mode even if
the -i command line switch was not given?
I want py2exe to create an interactive session, without writing my own
REPL.
Thanks.
--
|
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.
|
by: bill |
last post by:
Is there a nice interactive JavaScript interpreter, analogous to
Python's or Perl's (perldb)? I'm looking for something for Linux,
and that supports readline. I want to be able to try out small
snippets of JavaScript code without having to rely on a browser.
Many thanks!
-bill
|
by: pkassianidis |
last post by:
Hello everybody,
I have written a python script which executes some functions and then
returns to the python interactive shell prompt (In other words I use
the command
"#!/usr/bin/python -i " in the script's header.
In this script I register my own handler for the SIGINT and SIGTERM
handlers but when I press Control-C the default handler is invoked and
the message "KeyboardInterrupt" is displayed. If I don't allow the
script to return...
| |
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...
|
by: Jan Kanis |
last post by:
Hello everyone,
I'm trying to change the interactive python prompt. According to the docs
this is done by changing sys.ps1 and sys.ps2 . That works fine when
running python interactively from a command line, but when running in IDLE
the .ps1 and .ps2 don't seem to exist.
I suppose this has something to do with Idle and the python shell in it
both running in different processes, with the prompts generated by the
Idle process?
|
by: Matimus |
last post by:
On Apr 11, 2:32 am, Evan <xdi...@gmail.comwrote:
Do you want a custom shell that does whatever you want? Or do you want
an interactive python shell that has some custom commands?
For the first check out the cmd module
http://docs.python.org/lib/module-cmd.html
example:
|
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...
|
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
|
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...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |