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

defined() doesn't work correctly

P: n/a
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
Nov 2 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
define(ROSTER_DIED,1);
According to the PHP Manual, your first argument must be a string. ie:
define('ROSTER_DIED', 1);
Then you can refer to it without the quotes (ie $this = ROSTER_DIED)
if (defined(ROSTER_DIED))
This should also be a string ie: defined('ROSTER_DIED')

See if that helps.

Nov 2 '06 #2

P: n/a
In article <11**********************@h54g2000cwb.googlegroups .com>,
ad*******@gmail.com says...
define(ROSTER_DIED,1);
According to the PHP Manual, your first argument must be a string. ie:
define('ROSTER_DIED', 1);
Then you can refer to it without the quotes (ie $this = ROSTER_DIED)
if (defined(ROSTER_DIED))
This should also be a string ie: defined('ROSTER_DIED')

See if that helps.
Yes, that worked.
--
PleegWat
Remove caps to reply
Nov 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.