samtwilliams Posted June 23, 2010 Share Posted June 23, 2010 Can anyone enlighten me as to why i get: Notice: Undefined variable: global_error_reporting in C:\wamp\www\inc\settings.php on line 35. //error handler function function customError($errno, $errstr) { if ($global_error_reporting == 0) { } elseif ($global_error_reporting == 1) { $myFile = $www_location."inc\error_log.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "Error: [$errno] $errstr "; fwrite($fh, $stringData); fclose($fh); } elseif ($global_error_reporting == 2) { echo "<b>Error:</b> [$errno] $errstr"; } elseif ($global_error_reporting == 3) { $myFile = $www_location."inc\error_log.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "Error: [$errno] $errstr "; fwrite($fh, $stringData); fclose($fh); echo "<b>Error:</b> [$errno] $errstr"; } } The variable is set further up the page. Thanks Sam Quote Link to comment Share on other sites More sharing options...
awjudd Posted June 23, 2010 Share Posted June 23, 2010 It means that you haven't actually set a value to it before trying to use the value in a statement. Was this supposed to be a global variable? If yes, you need to tell PHP this. <?php function customError($errno, $errstr) { global $global_error_reporting; // Tell PHP to look in the global scope rather than local. ... } ~juddster Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.