473,797 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
13 1863
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*******@attgl obal.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
7425
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 (text/html) for this document is used to serve both SGML and XML based documents, and it is not possible to disambiguate it based on the DOCTYPE Declaration in your document. Parsing will continue in SGML mode."...
7
2325
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 applied, which are ignored, which are inherited or not, which are superceded, etc. This would be a huge aid in debugging pages. (I currently have a page that is included by another page - it's actually a menu - but it's rendered differently...
1
2577
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 macros and the VB side of the application. I have been put to the task of building a tool in which will validate when one user has transferred an clients casefile to another user. as this is a windows NT environment i am using the NT usernames...
26
25620
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 idea? Thanks you very much
1
4008
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. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
1
6471
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 is the code... SOMEBODY PLEASE HELP ME!! I'm going crazy! haha <?php //This contains user stuffs switch($_GET) { case 'newuser': new_user_form(); break; case 'newusersub': new_user_submit(); break; case 'edituser': edit_user_begin(); break;...
68
11188
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 my code: <?php //Connect To Database $hostname='mideasthonors2.db.4381361.hostedresource.com'; $username='**************'; $password='***********'; $dbname='mideasthonors2';
4
1884
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 files. but after that we need to clcik "analyse" button in that tool. and after it analyse whole file for about 1 minute we need to click on "save " button i want to automate this .. means make a script that does click buttons on an external software...
3
5069
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, unexpected T_VARIABLE in /home/content/m/i/x/mixxsalon/html/FormToEmail.php on line 1 here is the code. <?php $my_email = "user@example.com"; /*
0
9685
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
9536
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10468
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...
1
10205
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
10021
tracyyun
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...
0
9063
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...
0
6802
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3748
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.