<?php
function change_this(&$self = NULL)
{
$self = (object) array ('foo' => 100);
}
class test extends stdClass
{
public $foo = 1;
public function test()
{
change_this($this);
var_dump($this);
$this->test_this();
}
public function test_this()
{
var_dump($this);
}
}
$x = new test;
$x->test();
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/U1JWV on line 8
object(test)#1 (1) {
["foo"]=>
int(1)
}
object(test)#1 (1) {
["foo"]=>
int(1)
}
object(test)#1 (1) {
["foo"]=>
int(1)
}
object(test)#1 (1) {
["foo"]=>
int(1)
}
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/U1JWV on line 8
object(stdClass)#2 (1) {
["foo"]=>
int(100)
}
object(test)#1 (1) {
["foo"]=>
int(1)
}
object(stdClass)#2 (1) {
["foo"]=>
int(100)
}
object(test)#1 (1) {
["foo"]=>
int(1)
}