php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7320 variable to reference "magic" cast
Submitted: 2000-10-18 16:34 UTC Modified: 2000-10-19 06:53 UTC
From: lwest at free dot fr Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: Linux / Debian 2.2
Private report: No CVE-ID: None
 [2000-10-18 16:34 UTC] lwest at free dot fr
Container->item becomes a reference  after invoking any "Item" method: $container->item->Foo() 


PHP Sapi: apache / Apache 1.3.9 / apxs
Related php.ini directives:
  allow_call_time_pass_reference  = Off ; as recommended


-----------------SNIPPLET-----------

<?

class Item
{
 function Foo()
 {
  echo "calling Item::Foo\n";
 }
}

class Container
{
 var $item;

 function Container()
 {
  $this->item = new Item();
 }

 function callFoo()
 {
  $this->item->Foo();
 }
}


$c = new Container();

echo "<xmp>\nBEFORE:";
var_dump($c);

$c->callFoo();

echo "\nAFTER:";
var_dump($c);
echo "</xmp>";


?>


-----------------OUTPUT-----------


BEFORE:
object(container)(1) {
  ["item"]=>
  object(item)(0) {
  }
}
calling Item::Foo

AFTER:
object(container)(1) {
  ["item"]=>
  &object(item)(0) {
  }
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-19 06:53 UTC] stas@php.net
This is intended behaviour.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 22:00:02 2026 UTC