Hi Jermo,

Are you getting an error message if you set E_STRICT?
Actually this code is not supposed to work in the first place. The reason is that you are only allowed to return variables by reference (like in many other languages). There was a bug in PHP 4 and early versions of PHP 5 which allowed you to get around this. In PHP, if you put parentheses around variables like you did, that becomes a read-only expression, very much like (2+2). There is really no way of resolving that behavior. We are supposed to print a warning or strict message when this happens but I can't check it right now.
What is the behavior you are getting?


Andi


At 09:01 PM 3/5/2005 -0500, Yermo Lamers wrote:

Thanks to michaels (at) crye-leike.com for the followup. He produced a
much shorter version of the code that produces the same result:

<?php
class Foo {
  function &getThis() {
    return( $this );
  }
  function destroyThis() {
    $baz =& $this->getThis();
  }
}
$bar = new Foo();
$bar->destroyThis();
var_dump($bar);
?>

Interestingly if you change the return( $this ) in &getThis() to return
$this; the bug is reproduced. Weird, parentheses making the difference.

I had thought it was related to the depth of subclasses and the particular
arrangement of members; i.e. classic buffer overrun symptoms.

So I stand corrected.

As a followup question, if I have a large body of code for which I cannot
produce a small test case what's the recommended approach to tracking it
down .. pass it by here before posting the bug report? I've still got that
weird PHP 4.3.10 bug that should also get resolved.

----------------------------------------------------------------------------
DTLink Software                                 http://www.dtlink.com
       Desktop Software and Web Applications
----------------------------------------------------------------------------

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to