Forum Moderators: coopster

Message Too Old, No Replies

PHP5.1 bug?

only var can be passed by ref !

         

henry0

7:09 pm on Sep 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All my scripts on PHP5 were OK up to now!

since updating to 5.1

I get an error from some files
"Only variables can be passed by reference"

It seems to be some discussions going on about that error

Looks like a bug when using array_pop() as I do within the files creating the error

But I am not sure that array_pop is the only culprit

Any ideas?

Thanks

Henry

henry0

11:30 am on Sep 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I made the mistake of posting a topic of secondary importance on the weekend :)

Have you heard of anything about that bug?

So far everyone is free to find a personalized "walk around"

But why array_pop() will be somehow disallowed? Or is it really a bug?

If it is the implications are quite big for every scripts using array_po() will need modif (under 5.1).

dcrombie

1:51 pm on Sep 6, 2005 (gmt 0)



[bugs.php.net...]

According to another site you can "fix the problem by assigning the value to a variable before passing it to array_pop()".

henry0

2:16 pm on Sep 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks
What we know:
4.4 cannot be fixed
and 5.1 has no fix yet

<<<
"fix the problem by assigning the value to a variable before passing it to array_pop()".
>>>
Sure it will work but it is a pain to go back to the drawing board, do a search a fix all arry_pop().

dcrombie

3:53 pm on Sep 6, 2005 (gmt 0)



The problem doesn't affect all calls to array_pop. This will work:

array_pop($array);

but not this:

array_pop(<function which returns an array>);

IMHO the former is better coding practice anyway..

henry0

4:12 pm on Sep 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As is worked in 5.0
Not with 5.1

for($i=$pos; $i<$this->records-1; ++$i)
$index[$i] = $index[$i+1];

// del the last array item
array_pop($index);

($index is previously written to and is used by a cal of events using a flat DB)

I am sure that final 5.1 release will address it.