Hello,
I have this simple but weird thing, at least for me
[PHP]
<?php
class a{
function __construct(){
$this->data='6';
b::b();
//$a=b::b();
}
function get(){
exit($this->data);
//exit($a);
}
}
class b{
function b(){
$this->data='9';
return $this->data;
}
}
$a = new a();
$a->get();
?>
[/PHP]
output is 9, but I would expect to be 6. If I call the b::b, I would suspect that return value could be stores in a variable ($a), but instead everything that was set in function b overwrites the same variables in class a... is this normal?
I have this simple but weird thing, at least for me
[PHP]
<?php
class a{
function __construct(){
$this->data='6';
b::b();
//$a=b::b();
}
function get(){
exit($this->data);
//exit($a);
}
}
class b{
function b(){
$this->data='9';
return $this->data;
}
}
$a = new a();
$a->get();
?>
[/PHP]
output is 9, but I would expect to be 6. If I call the b::b, I would suspect that return value could be stores in a variable ($a), but instead everything that was set in function b overwrites the same variables in class a... is this normal?
Comment