Reply to Re: [PHP] debugging

Your name:

Reply:


Posted by William Stokes on 01/19/05 10:35

I'm trying to get the ini_set("error_reporting",E_ALL); work. No matter what
kind of errors I write I just get blank screen when the script fails. Do I
need to also echo the errors to screen? Or can the error reporting be
disabled by the server admin (my adsl operator)? so that no errors are
printed to screen.

I just set the error reporting at the beginning of the code like:

<?php
ini_set("error_reporting",E_ALL);
etc...

thanks
-Will

"Justin French" <justin.french@indent.com.au> kirjoitti
viestissδ:3902E10C-69EC-11D9-96D6-000A9579CE3A@indent.com.au...
> On 19/01/2005, at 5:36 PM, William Stokes wrote:
>
>> I would like to add some debugging/info code to my pages. In test
>> environment of course. Any ideas how to do this? I mean for example to
>> print
>> to a web page the line number when the script fails or something like
>> that.
>> It's a pain on the **s to hunt typo's by just reading the source over and
>> over again.
>
> William,
>
> I start by trying to programatically find out if I'm in a development or
> production environment and setting a constant DEV to true or false. For
> me, I development things on my desktop Mac, so the server and client are
> the same machine, and share the same IP address. So my check for DEV is
> if the client IP and server IP match.
>
> <? define('DEV',($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR'])); ?>
>
> So, this then gives a constant DEV to test to decide if I'm in the
> development or production environment, eg:
>
> Next, I set-up PHP's built-in error reporting for both environments:
>
> <?
> if(DEV)
> {
> ini_set("error_reporting",E_ALL);
> ini_set("display_errors",1);
> ini_set("log_errors",0);
> }
> else
> {
> ini_set("error_reporting",E_ALL ^ E_NOTICE);
> ini_set("display_errors",0);
> ini_set("log_errors",1);
> }
> ?>
>
> In short, this logs most errors in production (not notices), and dumps
> them to the screen if we're in development. You'll already see that you
> get quite a lot of information from the errors (line numbers, reason for
> the error, etc), and I think this is what you're looking for.
>
> But so far this only caters to PHP errors triggered by built-in functions
> and source. Smarter programmers will build in their own debugging lines,
> custom errors and notices to make the tracking down of bugs and quirks
> much much easier. For this, you can use trigger_error()
> <http://au2.php.net/trigger_error>.
>
>
> That should be more than enough for the average PHP hack, but there is of
> course the option to write your own custom error handler to customise the
> look and feel of the error messages, send emails, log things to a
> database, etc.
>
> It's all pretty powerful stuff, so read up!
>
>
> ---
> Justin French, Indent.com.au
> justin.french@indent.com.au
> Web Application Development & Graphic Design

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация