Jump to content
Larry Ullman's Book Forums

Recommended Posts

I haven't been on the forum in quite a while so haven't asked a dumb question which probably catagorizes the following:

 

Within the error management section of the book there is the following code:

if (!LIVE ) { // Development (print the error).

        // Show the error message:
        echo '<div class="error">' . nl2br($message);
    
        // Add the variables and a backtrace:
        echo '<pre>' . print_r ($e_vars, 1) . "\n";
        debug_print_backtrace();
        echo '</pre></div>';

etc....

}

This will give all errors and notices including undefined variables. I do want the undefined variable notices EXCEPT if they are included in an  if (isset ()) conditional, which I don't care about.

 

So,

if (!LIVE && ($e_number != E_NOTICE) )}

 

won't work because it won't point out $thisVar if it is not defined.

 

Is there a way to shield the "isset" qualified variables.

 

 

 

Link to comment
Share on other sites

Okay, I did a dumb programming maneuver, but I still got it to throw an error from within isset().

 Here's what I had:

 

Note: $galleries[2] has a string value and $gal3 has no value.

<input type="checkbox" name="<?php echo $galleries[2];?>"

<?php if (isset($_POST[$gal3])) echo 'checked = "checked"' ?> />

<?php echo" ". $galleries[2];?><br /><br />

The error was for this particular line number (containing the above the checkbox field) and the culprit variable that was "undefined" is gal3. Even though it is in an isset().

 

 

My solution, which I should have had in the beginning, was simply to replace the  $_POST[$gal3]  with  $_POST[$galleries[2]].

So, though everything works now, I'm still a bit curious as to why the error?

 

It can remain a mystery, that will be okay, Thank you for your help.

Link to comment
Share on other sites

 Share

×
×
  • Create New...