Re: [PHP] Function returning but continues execution



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.
.



Relevant Pages

  • Re: [PHP] Function returning but continues execution
    ... surely suggests some kind of issue somewhere in PHP itself. ... and the bug appears. ... echo "I've been called $foo times\n"; ... scalable system for accessing system services | ...
    (php.general)
  • Re: Case sensitivity in programming languages.
    ... Every time someone creates a post about case sensitve languages I reserve ... At least not in PHPP, ... Thus I can create different things called 'foo' and reference each ... sensitive languages trying to force case sensitivity into ALL languages. ...
    (comp.lang.php)
  • Re: [Full-disclosure] Fwd: FreePBX Unfounded RCE PoC or rather Misguided PoC maybe ?
    ... OK well, after trying again with the php code, but corrected php code, i ... dont think it is possible to save a page.. ... I have written 3 or so PoC's for this and also for another bug in this, ... allowed to specify a path to upload a file to. ...
    (Full-Disclosure)
  • Re: php extensions compile error - another compile bug?
    ... Re: php extensions compile error - another compile bug?: ... Is not triviality is a matter of perspective? ... AFFECTS: users of PHP ... and shared extensions to allow more flexibility and add new features. ...
    (freebsd-questions)
  • Multibyte Wackiness on RHEL
    ... should upgrade to PHP 5.2. ... Test DateTimeZone::listIdentifiers function: basic functionality ... SPL: ... Bug #48770 fails to call parent from inheriting ...
    (comp.lang.php)