Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
January 18, 2012, 11:50 pm
rate this thread
In my XP env (xp, apache, php 5.3.8) this will work:
On a linux box, apache, php 5.3.6, it does not. Says " Call-time pass-
by-reference has been deprecated"
But this is allowed...
$param_array[$i] = &$include_unique[$i];
Is there a way to use a push with a reference construct?
- "Ãlvaro G. Vicario"
January 19, 2012, 8:50 am
Re: array_push() v/s array[$index] = and reference construct &
I guess you need to enable error reporting in your Windows set-up.
Certainly, since it isn't a function call.
The key point about "Call-time pass-by-reference" is that, when you want
to pass a parameter as reference, it needs to be defined as such within
the function; you cannot decide it at run time. E.g.:
$foo = 33;
«Deprecated: Call-time pass-by-reference has been deprecated; If you
would like to pass it by reference, modify the declaration of f(). If
you would like to enable call-time pass-by-reference, you can set
allow_call_time_pass_reference to true in your INI file»
However, this works as expected no matter your settings:
$foo = 33;
Unluckily, array_push() is a core PHP function written in C, not some
PHP code you can modify. So your options are:
1. Enable allow_call_time_pass_reference
2. Write your own function to implement this behaviour
Of course, array_push() is only useful when you need to append more than
one item at a time.
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com