473,394 Members | 2,048 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,394 software developers and data experts.

Picking Up Parsing etc. Errors in PHP

I'm using Kate in Linux (and UltraEdit when I have to drop back into
Windows) for writing my PHP code. As a independent, self-employed
developer, I cannot afford a commercial IDE for PHP such as is provided
by Zend.

I'm running PHP (with Apache) on my own machine for my development work.

Is there some way ("strict" settings in the php.ini file, or whatever)
by which I can cut down the time I'm wasting searching for, and
recovering from, silly syntax errors in the code I write?

I've just spend a day, for example, finding a complex two-condition 'if'
statement where I'd simply forgotten to supply the outermost pair of
brackets. The only symptom I was getting was a total absence of HTML
output to the page, and my only debugging "tool" was the provision of
'echo' statements at various places down the PHP code, coupled with the
total commenting out of all PHP code beyond the one currently being tried.

If anybody knows of a free- or shareware PHP syntax checking tool for
Linux, I'd be grateful if they could let me know.
Feb 8 '08 #1
3 1375
*** Anonymous escribió/wrote (Fri, 08 Feb 2008 19:38:54 +0100):
Check your php.ini for the following:

error_reporting = E_ALL
Or even better (for PHP 5):

error_reporting = E_ALL | E_STRICT
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor austrohúngaro: http://www.demogracia.com
--
Feb 8 '08 #2
On Fri, 08 Feb 2008 18:58:27 +0100, Alan M Dunsmuir
<al**@moonrake.demon.co.ukwrote:
I'm using Kate in Linux (and UltraEdit when I have to drop back into
Windows) for writing my PHP code. As a independent, self-employed
developer, I cannot afford a commercial IDE for PHP such as is provided
by Zend.

I'm running PHP (with Apache) on my own machine for my development work.

Is there some way ("strict" settings in the php.ini file, or whatever)
by which I can cut down the time I'm wasting searching for, and
recovering from, silly syntax errors in the code I write?

I've just spend a day, for example, finding a complex two-condition 'if'
statement where I'd simply forgotten to supply the outermost pair of
brackets. The only symptom I was getting was a total absence of HTML
output to the page, and my only debugging "tool" was the provision of
'echo' statements at various places down the PHP code, coupled with the
total commenting out of all PHP code beyond the one currently being
tried.

If anybody knows of a free- or shareware PHP syntax checking tool for
Linux, I'd be grateful if they could let me know.
Aside from the allready mentioned method to just run PHP and check the
errors, here's one that I use with my favourite editor: php -l
/path/to/file/name.php will ONLY do a syntax check, and report the result.
No more having to go through the webserver, run the entire code, perhaps
endlessly type urls/refresh windows. Just a simple key combination in the
editor here does it.
--
Rik Wasmus
Feb 8 '08 #3
In article <op***************@metallium.lan>,
Rik Wasmus <lu************@hotmail.comwrote:
><al**@moonrake.demon.co.ukwrote:
>Is there some way ("strict" settings in the php.ini file, or whatever)
by which I can cut down the time I'm wasting searching for, and
recovering from, silly syntax errors in the code I write?

Aside from the allready mentioned method to just run PHP and check the
errors, here's one that I use with my favourite editor: php -l
/path/to/file/name.php will ONLY do a syntax check, and report the result.
That's a good suggestion. It should also catch instances where you use
a variable before it's initialized.

To debug online, I have an initialization script that is included
at the top of every single script I have. Among other things, the
initialization has the following lines:

if (SHOW_WARN) { // This is set in my config.php script
$errlog = "/home/my_account/some_path/error.log"; // error log file
if (file_exists($errlog)) unlink($errlog); // remove prev. error log
ini_set('display_errors', false); // prevent pre-header abort
ini_set('log_errors', true); // enable error logging
ini_set('error_log', $errlog); // set error log file
error_reporting(E_ALL); // report all errors
}

....and then at the bottom of my master page template I simply
display the error log if it exists, within <pre>...</pretags.

This method is necessary when one can't use php -l. One can't use
php -l when the execution of your script depends on cookies, login
data and other session-related data, responses from FORM submissions,
etc.

-A

-A
Feb 8 '08 #4

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
0
by: Ewan B | last post by:
Hi, I'm using Xerces to parse XML files using SAX2, and am wondering if there is any information as to what exceptions are being thrown when certain validation errors occur. Taking a simple...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
2
by: Chris | last post by:
I've added a configuration file similar to Web.config but that does not invoke a restart when changed, just a cache dependency. At various times I'm getting a seeingly random one of the following...
0
by: gallagherg | last post by:
I recieve a Parsing returned error message 0x800700003 along with Actve x/com errors how can i stop this?
24
by: Marc Dubois | last post by:
hi, is it possible to parse an XML file in C so that i can fulfill these requirements : 1) replace all "<" and ">" signs inside the body of tag by a space, e.g. : Example 1: <fooblabla < bla...
26
by: Ramon F Herrera | last post by:
http://groups.google.com/group/comp.lang.c/browse_frm/thread/86a3ddf0724d9630/4e38340aa824bee0?lnk=gst&q=how+to+best+parse+a+CSV&rnum=1#4e38340aa824bee0 http://tinyurl.com/29q4kf Michael & Paul...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
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
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...
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.