done debuggin, now what?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

done debuggin, now what?

Post by Zoram »

When I have finished debugging a script how do i make it so that it doesn't display the errors etc when there is an error....?
waskelton4
Forum Contributor
Posts: 132
Joined: Mon Sep 09, 2002 6:42 pm

Post by waskelton4 »

if your server is win

Edit php.ini so..

display_errors = off

there are also switches, if you like, to post your errors/warnings/notices to a file.
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post by Zoram »

I dont' have access as far as i know to the ini file.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://www.php.net/manual/en/ref.errorf ... -reporting

Code: Select all

error_reporting		E_ALL & ~E_NOTICE		PHP_INI_ALL 
display_errors		"1"			PHP_INI_ALL
you can change those values with ini_set
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

Put this at the top of each script:

// Turns off error reporting for the duration of the script the function is called in
error_reporting(0);
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can use the '@' symbol in front of a line of code to suppress any errors that might arise that you can't prevent, eg:

Code: Select all

@mail($to, $subject, $message);
there's also the or die() statement to quit a script when something like a database is down:

Code: Select all

@mysql_connect($host, $user, $pass) or die(error_message());
you can put a custom function call into the die() function so that you can decide how errors are displayed.

IMHO, you shouldn't need to turn error_reporting off if you've done thourough testing of your site before making it live and got rid of errors that are under your control as well adding procedures to catch those that aren't especially when it comes to dodgy user input.

Mac
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Thanks Twigletmac!

Post by Zoram »

That's what i was looking for! Thanks!
Post Reply