...

View Full Version : Can someone simplify this error_reporting code?



kaisellgren
05-15-2008, 03:58 PM
Hello,

I have this:


error_reporting(E_ERROR | E_PARSE | E_NOTICE | E_WARNING | E_CORE_ERROR | E_CORE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE);

I want to show all errors EXCEPT E_STRICT, because my wysiwyg produces strict errors.

Since PHP 5.3 I guess, E_STRICT is part of E_ALL, and I can not type E_ALL & ~E_STRICT because in PHP 4.x it will throw an error, because PHP 4 does not know E_STRICT.

aedrin
05-15-2008, 04:14 PM
Since PHP 5.3 I guess, E_STRICT is part of E_ALL, and I can not type E_ALL & ~E_STRICT because in PHP 4.x it will throw an error, because PHP 4 does not know E_STRICT.

There are still hosts out there that use PHP4? Supporting PHP4 is like supporting IE5, it's rather a pointless effort.

Either way, if your long version works I think you'll just have to stick with that.

_Aerospace_Eng_
05-15-2008, 05:30 PM
According to the Change Log E_STRICT isn't part of E_ALL until PHP 6.
ChangeLog

Version Description
5.0.0 E_STRICT introduced (not part of E_ALL).
5.2.0 E_RECOVERABLE_ERROR introduced.
6 E_STRICT became part of E_ALL.

I guess you could do this

<?php
if(substr(phpversion(),0,1) == '4')
{
error_reporting(E_ALL);
}
else
{
error_reporting(E_ALL & ~E_STRICT);
}
?>

kaisellgren
05-15-2008, 05:54 PM
According to the Change Log E_STRICT isn't part of E_ALL until PHP 6.
ChangeLog

Version Description
5.0.0 E_STRICT introduced (not part of E_ALL).
5.2.0 E_RECOVERABLE_ERROR introduced.
6 E_STRICT became part of E_ALL.

I guess you could do this

<?php
if(substr(phpversion(),0,1) == '4')
{
error_reporting(E_ALL);
}
else
{
error_reporting(E_ALL & ~E_STRICT);
}
?>
That's a good idea, I'm going to use it, thank you :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum