You are here: defined() doesn't work correctly « PHP Programming Language « IT news, forums, messages
defined() doesn't work correctly

Posted by PleegWat on 11/02/06 13:47

Hi,

I'm using this function:

function die_quietly( $text='', $title='', $file='', $line='', $sql='' )
{
global $wowdb, $roster_conf, $wordings, $roster_menu;

// die_quitely died quietly
if (defined(ROSTER_DIED))
{
print '<pre>The quiet die function suffered a fatal error.
Die information below'."\n";
print 'First die data:'."\n";
print_r($GLOBALS['die_data']);
print "\n".'Second die data'."\n";
print_r(func_get_args());
exit();
}

define(ROSTER_DIED,1);

$GLOBALS['die_data'] = func_get_args();

// Snip stuff that generates a graphical error page

exit();
}

The purpose of this function is creating a graphical error page if
something in my package causes a fatal error, rather than just dying.
The purpose of the quoted part is preventing undesired recursion if
something inside the die_quietly() function calls the die_quietly()
function again.

This code however doesn't work correctly. defined(ROSTER_DIED) seems to
return false on the second function call, and return true on the third.
Which means it returns the reason die_quietly failed twice, but not the
reason die_quietly was originally called.

Can anyone explain to me why this happens?
--
PleegWat
Remove caps to reply

 

Navigation:

[Reply to this 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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация