By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Picking Up Parsing etc. Errors in PHP

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
*** 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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.