473,385 Members | 1,337 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,385 software developers and data experts.

Tool to parse and validate PHP script?

Hello

Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?

I just noticed that I copy/pasted some code that had lines longer that
can fit in the SSH terminal window, and that caused a run-time error
as reported in the /var/log/httpd-error.log but not in the browser:

[error] PHP Notice: Undefined index: etablissemen\nt in
/usr/local/www/apache22/data/prospect.php on line 49, referer:
http://server/myscript.php

Thank you.
Jun 2 '08 #1
13 1824
Gilles Ganault wrote:
Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?

I just noticed that I copy/pasted some code that had lines longer that
can fit in the SSH terminal window, and that caused a run-time error
as reported in the /var/log/httpd-error.log but not in the browser:

[error] PHP Notice: Undefined index: etablissemen\nt in
/usr/local/www/apache22/data/prospect.php on line 49, referer:
http://server/myscript.php
You can run 'php -l thescript.php' to do a syntax check, however your
error would not be catched by that: this is a run time error, and only
catchable by actually running the script.

Of course, on live websites error should not be shown, but logged, as is
done her apparently.
--
Rik Wasmus
Jun 2 '08 #2
On May 8, 9:06 am, Rik Wasmus <luiheidsgoe...@hotmail.comwrote:
Gilles Ganault wrote:
Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
I just noticed that I copy/pasted some code that had lines longer that
can fit in the SSH terminal window, and that caused a run-time error
as reported in the /var/log/httpd-error.log but not in the browser:
[error] PHP Notice: Undefined index: etablissemen\nt in
/usr/local/www/apache22/data/prospect.php on line 49, referer:
http://server/myscript.php

You can run 'php -l thescript.php' to do a syntax check, however your
error would not be catched by that: this is a run time error, and only
catchable by actually running the script.

Of course, on live websites error should not be shown, but logged, as is
done her apparently.
--
Rik Wasmus
Any chance to transfer your file by ftp or sftp?
Jun 2 '08 #3
On Thu, 8 May 2008 06:14:40 -0700 (PDT), ELINTPimp wrote:
>Gilles Ganault wrote:
Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
I just noticed that I copy/pasted some code that had lines longer that
can fit in the SSH terminal window, and that caused a run-time error
as reported in the /var/log/httpd-error.log but not in the browser:
[error] PHP Notice: Undefined index: etablissemen\nt in
/usr/local/www/apache22/data/prospect.php on line 49, referer:
http://server/myscript.php

Any chance to transfer your file by ftp or sftp?
Or use a better configuration on the editor....

--
This was, apparently, beyond her ken. So far beyond her ken that she was
well into barbie territory.
-- J. D. Baldwin
Jun 2 '08 #4
ELINTPimp wrote:
On May 8, 9:06 am, Rik Wasmus <luiheidsgoe...@hotmail.comwrote:
>Gilles Ganault wrote:
>> Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
I just noticed that I copy/pasted some code that had lines longer that
can fit in the SSH terminal window, and that caused a run-time error
as reported in the /var/log/httpd-error.log but not in the browser:
[error] PHP Notice: Undefined index: etablissemen\nt in
/usr/local/www/apache22/data/prospect.php on line 49, referer:
http://server/myscript.php
You can run 'php -l thescript.php' to do a syntax check, however your
error would not be catched by that: this is a run time error, and only
catchable by actually running the script.

Of course, on live websites error should not be shown, but logged, as is
done her apparently.

Any chance to transfer your file by ftp or sftp?
What do you mean? 'my file'?

--
Rik Wasmus
Jun 2 '08 #5
On Thu, 8 May 2008 06:14:40 -0700 (PDT), ELINTPimp <sm*****@gmail.com>
wrote:
>Any chance to transfer your file by ftp or sftp?
I could do that instead. I'll just have to remember to convert from
CRLF to CR.

Thanks for the "-l" switch.
Jun 2 '08 #6
On May 8, 9:59 am, Rik Wasmus <luiheidsgoe...@hotmail.comwrote:
ELINTPimp wrote:
On May 8, 9:06 am, Rik Wasmus <luiheidsgoe...@hotmail.comwrote:
Gilles Ganault wrote:
Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
I just noticed that I copy/pasted some code that had lines longer that
can fit in the SSH terminal window, and that caused a run-time error
as reported in the /var/log/httpd-error.log but not in the browser:
[error] PHP Notice: Undefined index: etablissemen\nt in
/usr/local/www/apache22/data/prospect.php on line 49, referer:
http://server/myscript.php
You can run 'php -l thescript.php' to do a syntax check, however your
error would not be catched by that: this is a run time error, and only
catchable by actually running the script.
Of course, on live websites error should not be shown, but logged, as is
done her apparently.
Any chance to transfer your file by ftp or sftp?

What do you mean? 'my file'?

--
Rik Wasmus
Sorry, Rik, I replied to the wrong comment. I was referring to the
posters copy/paste method being the problem and skip the need for
checking this post-transfer altogether by transferring the file they
created (and presumably tested) instead of copy/paste over ssh.
Jun 2 '08 #7
Gilles Ganault wrote:
On Thu, 8 May 2008 06:14:40 -0700 (PDT), ELINTPimp <sm*****@gmail.com>
wrote:
>Any chance to transfer your file by ftp or sftp?

I could do that instead. I'll just have to remember to convert from
CRLF to CR.
I often work under Windows, however, even under Windows my editor is set
up to \n instead of \r\n all the time. Saves a lot of headaches.

--
Rik Wasmus
Jun 2 '08 #8
Rik Wasmus wrote:
Gilles Ganault wrote:
>On Thu, 8 May 2008 06:14:40 -0700 (PDT), ELINTPimp <sm*****@gmail.com>
wrote:
>>Any chance to transfer your file by ftp or sftp?

I could do that instead. I'll just have to remember to convert from
CRLF to CR.

I often work under Windows, however, even under Windows my editor is set
up to \n instead of \r\n all the time. Saves a lot of headaches.
A text mode transfer will automatically strip or add \r as necessary.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #9
Gilles Ganault wrote:
Hello

Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
You will never have a compile-time error with PHP since PHP is a script
and, hence, doesn't compile. Perhaps you mean run-time issues?
Jun 2 '08 #10
On Thu, 08 May 2008 17:22:59 -0400, sheldonlg <sheldonlgwrote:
>You will never have a compile-time error with PHP since PHP is a script
and, hence, doesn't compile. Perhaps you mean run-time issues?
No, I meant syntax errors that could be picked by just parsing the
source, so those simple issues are detected before actualling running
the program. "php -l" did the trick (along with "... or die" to detect
faulty SQL commands). Thanks.
Jun 2 '08 #11
Gilles Ganault wrote:
On Thu, 08 May 2008 17:22:59 -0400, sheldonlg <sheldonlgwrote:
>>You will never have a compile-time error with PHP since PHP is a script
and, hence, doesn't compile. Perhaps you mean run-time issues?

No, I meant syntax errors that could be picked by just parsing the
source, so those simple issues are detected before actualling running
the program. "php -l" did the trick (along with "... or die" to detect
faulty SQL commands). Thanks.
some editors have syntax checking, as for example jEdit (www.jedit.org) with
phpparser plugin installed.

--
a.d.
Jun 2 '08 #12
Sir Robin wrote:
On Thu, 08 May 2008 17:22:59 -0400, sheldonlg <sheldonlgwrote:
>Gilles Ganault wrote:
>>Hello

Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
You will never have a compile-time error with PHP since PHP is a script
and, hence, doesn't compile. Perhaps you mean run-time issues?

As far as I understand PHP does in fact first compile the script to byte-code
and then run it... Surely if the code has syntax errors it would result to
compile time error, right?
No, Gilles is correct. PHP is not compiled. It is interpreted. A big
difference. And no, syntax errors are not considered compile-time errors.

Java, OTOH, is compiled to byte code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #13
..oO(Jerry Stuckle)
>Sir Robin wrote:
>On Thu, 08 May 2008 17:22:59 -0400, sheldonlg <sheldonlgwrote:
>>Gilles Ganault wrote:
Hello

Is there a tool on Linux/FreeBSD that can parse a PHP script to make
sure there's no compile-time issues?
You will never have a compile-time error with PHP since PHP is a script
and, hence, doesn't compile. Perhaps you mean run-time issues?

As far as I understand PHP does in fact first compile the script to byte-code
and then run it... Surely if the code has syntax errors it would result to
compile time error, right?

No, Gilles is correct. PHP is not compiled. It is interpreted.
It's both (hence some even call PHP an "interpiler"). The source code is
compiled into a byte code, which is then interpreted by the Zend engine.
Two steps, two different things.

Caches like APC for example store the _compiled_ code.
>A big
difference. And no, syntax errors are not considered compile-time errors.
It's the parser which chokes upon them, not the interpreter. So they can
be called compile-time errors.
>Java, OTOH, is compiled to byte code.
Which is then executed/interpreted by the VM. Quite similar to PHP, just
done more independently.

Micha
Jun 2 '08 #14

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

Similar topics

8
by: Spartanicus | last post by:
The document at http://homepage.ntlworld.com/spartanicus/custom_dtd.htm uses a custom DTD, the w3c validator validates it but with this warning: "Unknown Parse Mode! The MIME Media Type...
7
by: ab3331 | last post by:
I need a tool that acts like a browser, but instead of actually rendering a page, it explains in English exactly what rules it's interpreting. This would make it simple to see which rules are...
1
by: vbnewb | last post by:
Hey All, I am new to the forums. Have been reading a bit here on some very useful tips and tutorials here. I am familiar with the basics of Access (tables , queries, forms,) but am such a newb at...
26
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
1
by: FightClubDiego | last post by:
Hey.. I've been working on these sign up / log in forms for my new Game Site, and everything else in the game works but the registration!! I keep ketting the unexpected $end and Im tired of it! Here...
68
mideastgirl
by: mideastgirl | last post by:
I keep getting this error and I cannot figure it out. My curly brackets are closed, and I am using the correct tags for <?php to open and ?> to close my code. Can someone please help me! Here is...
4
by: kanishka1213 | last post by:
i am trying to make a script that recognizes all unparsed stream files from folder and runs an external tool in windows system to parse them. so far i am able to call that tool for all unparsed...
3
by: broll911 | last post by:
I am gettin a error message on this script can someone help me. I am a complete newbie on this stuff. Thanks in advance for any help you can give me. here is the error. Parse error: syntax error,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.