I added this in and it outputs 1 as I suspected - the function is being
called only once.
David
Robert Cummings wrote:
On Mon, 2007-01-22 at 16:36 +0000, David Mytton wrote:
Yes, I know it looks like a bug in my code because I'm not able to write
a test case that can reproduce it simply enough to report as a bug -
hence why I am posting here. However, the behaviour I am describing
surely suggests some kind of issue somewhere in PHP itself.
My reasoning for this is if I echo the 2 variables I get:
Array ( [0] => 3 )
and
3
and the bug appears. But if I set them manually before the in_array test:
$_SESSION['user']['friends'] = array(0 => 3);
$friend['user_id'] = 3;
it works as expected. Am I wrong in thinking that this has to be a bug
in PHP?
I have used debug_backtrace() to find out what is going on as regards
how many times the function is being executed - that is the first thing
I checked because it does indeed suggest that it is being executed
multiple times, however, the back trace only reveals 1 call/execution.
A backtrace won't indicate multiple calls unless they are recursive. Try
add the following to your function:
<?php
static $foo = 0;
$foo++;
echo "I've been called $foo times\n";
?>
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php