note 44056 deleted from language.operators.errorcontrol by tomsommer

From: Date: Tue, 13 Jul 2004 22:06:29 +0000
Subject: note 44056 deleted from language.operators.errorcontrol by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73188@lists.php.net to get a copy of this message
Note Submitter: john ---- To avoid all the "Notice: Undefined index: ..." with error_reporting(E_ALL) when incrementing an undefined array index, try the following function instead: <?php error_reporting(E_ALL); $array1['newindex1']++; // Notice: Undefined variable: array1 in /home/user/www/test.phtml on line 4 // Notice: Undefined index: newindex1 in /home/user/www/test.phtml on line 4 incr($array2['newindex2']); // no notice. $array2['newindex2'] set to 1. function incr(&$var, $amt = 1) { // note the pass by reference if (!isset($var)) {$var = $amt;} else {$var += $amt;} } ?>

« previous php.notes (#73188) next »