ID:               50748
 User updated by:  gahgneh+php at gmail dot com
 Reported By:      gahgneh+php at gmail dot com
 Status:           Bogus
 Bug Type:         Variables related
 Operating System: Windows XP SP3
 PHP Version:      5.2.12
 New Comment:

I usually prefer to check if the variable(s) are empty before calling
indexes on them. Or make it able to func_get_args() to pass variables by
reference, or extend isset() and empty() to check multiple items. If the
parameter is not a reference, PHP gives a undefined index notice.


Previous Comments:
------------------------------------------------------------------------

[2010-01-14 11:16:51] [email protected]

For passing references we would need to know at the time the parameters
are prepared, before actually invoking the function, that references are
expected. That can only be done by defining it in the signature ... but
when doing that func_get_args() is rather useless - the only case would
be an undefined number of reference parameters which can be simulated by
using an array of references as parameter ... but then again: There's
barely any reason for using references these days in PHP.

------------------------------------------------------------------------

[2010-01-14 11:00:04] gahgneh+php at gmail dot com

Description:
------------
func_get_args() should be able to pass variables as reference

Reproduce code:
---------------
function ref(){
  $args = func_get_args();
  $args[0] = 10;
  $args[1] = 11;
}

$value = 0;
$value2 = 1;
ref($value, $value2);

echo $value,$value2; // prints 01

Expected result:
----------------
$value to contain "int 10" and $value2 to contain "int 11"
There should be a * pointer operator like C++, to tell the variable to
behave like
function ref(int* p = null){ *p = 10; }



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50748&edit=1

Reply via email to