Forum Moderators: coopster
Can anyone see anything wrong with this code?
If I remove the "$test -> control -> dump();" line, everything works.
<?php//could be written in a shorter way, but lets be obvious.
error_reporting(E_ALL ¦ E_STRICT ¦ E_CORE_ERROR ¦ E_CORE_WARNING ¦ E_COMPILE_ERROR ¦ E_COMPILE_WARNING ¦ E_USER_ERROR ¦ E_USER_WARNING ¦ E_USER_NOTICE );
class Control{
public $key = null;
public function dump(){
var_dump($this->key);
}
}
class Form {
public $control = null;
function __set($a, $b){
$b->key = $a;
var_dump($a);
var_dump($b);
$this->control = $b;
}
}
$test = new Form();
$key = '123';
$test->$key = new Control();
$test -> control -> dump();
echo 'completed';
exit;
Server Error
The following error occurred:
[code=SERVER_RESPONSE_CLOSE] The server closed the connection while reading the response. Contact your system administrator.
Please contact the administrator.
error when I have the:
$test -> control -> dump();
line in, but works fine when
//$test -> control -> dump();
is commented out.
thing3b, perhaps you can gain an understanding from the example in the PHP manual regarding References inside the constructor [php.net] as well as References Explained [php.net].
I know what the & should do, but this issue is not a coding error, but a bug in the way PHP 5.0.4 is set up on my linux server. I am not sure if the bug is in PHP its self or one of the zend php extentions things.