|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2012-01-30 12:28 UTC] aharvey@php.net
  [2012-01-30 12:28 UTC] aharvey@php.net
 
-Status: Open
+Status: Wont fix
  [2012-01-30 17:21 UTC] luke at cywh dot com
  [2012-01-30 18:53 UTC] luke at cywh dot com
  [2013-12-29 22:23 UTC] info-php at swissbusinet dot com
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Thu Oct 30 18:00:02 2025 UTC | 
Description: ------------ It's usually a good practice to develop with the highest error level to eliminate all warnings and notices. There are some cases where you know a variable or array index won't be defined. So in order to eliminate the notice you write something like this: $value = isset($input['name']) ? $input['name'] : ""; I end up writing this a lot, especially with user input and templates. In many cases it's OK and intended the variable is undefined and the value is NULL. Another "solution" is to write this: $value = &$input['name']; But this only works when "&" is preceded by "=". You could also write this: $value = @$input['name']; But this only prevents the error from displaying. It is sill reported by error_get_last. We need a simple function like isset that returns the value or NULL. It could be used like this: $value = udef($input['name']); This is possible now with a user defined function (code below). But it would be nice to have a construct like isset/empty that did this. (Not shown in example, but perhaps it could take multiple arguments like isset and return the first non-NULL value it finds) Test script: --------------- function udef(&$var) { return $var; } $one = array(); print udef($one['one']); print_r($one); Expected result: ---------------- Array ( [one] => ) Actual result: -------------- Array ( [one] => )