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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lwest at free dot fr
New email:
PHP Version: OS:

 

 [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: Sun Oct 11 02:00:01 2026 UTC