defined() doesn't work correctly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PleegWat

    #1

    defined() doesn't work correctly

    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($GLOBAL S['die_data']);
    print "\n".'Secon d die data'."\n";
    print_r(func_ge t_args());
    exit();
    }

    define(ROSTER_D IED,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
  • adamraney@gmail.com

    #2
    Re: defined() doesn't work correctly

    define(ROSTER_D IED,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.

    Comment

    • PleegWat

      #3
      Re: defined() doesn't work correctly

      In article <1162486881.826 636.296230@h54g 2000cwb.googleg roups.com>,
      adamraney@gmail .com says...
      define(ROSTER_D IED,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

      Comment

      Working...