You can avoid the E_NOTICE using a reference, but it can have undesired side effects. For example, if you pass $x[5] by reference (whether to an internal function or a user defined function), $x[5] will be "created" and set to NULL. To avoid this side-effect, don't use the reference and instead use @$x[5] as the first argument to the function. (but DO NOT use @$x[5] as an argument to a function that takes a reference - it may cause a crash/corruption later.)
- Todd On Thu, 2004-04-15 at 13:14, Jason Garber wrote: > >I wrote this (I underlined the relevant parts for you): > > > > > >You'll need something more clever, because > > > >an undefined key 'CUST_ID' in $_POST['CUST_ID'] will strill throw a > > > Consider this: > > ----------------------------------- > <?php > > error_reporting(E_ALL); > > function setor(&$param, $default) > { > return (isset($param) ? $param : $default); > } > > > $x = setor($x, 10); ///Should Produce an E_NOTICE > > echo gettype($x) . ':' . $x . "\n"; > > ?> > ----------------------------------- > > This DOES NOT produce an E_NOTICE like you said (notice the &). However, > $param1 is defined and NULL inside the function, even though $x was not a > defined variable outside the function?? > > ~Jason -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php