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 Link to comment https://forums.phpfreaks.com/topic/205690-notice-undefined-variable-not-sure-why/ 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 Link to comment https://forums.phpfreaks.com/topic/205690-notice-undefined-variable-not-sure-why/#findComment-1076315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.