Reputation: 55
I have spent the last 20 minutes trying to work out the cause for this issue.
Firstly I will do
$this->is_csu = TRUE;
In a separate class I call isset, isset returns FALSE, if I immediately echo the variable it will return TRUE.
echo var_dump(isset($this->is_csu));
echo var_dump($this->is_csu);
die();
Results in an output of
bool(false) bool(true)
I'm sure there is some technical reason to why this is happening, but it is beyond me right now.
Hopefully someone can shed some light on this.
Upvotes: 0
Views: 2549
Reputation: 861
I know its a very old question , but it occurred to me as well and I could not figure out why.
The reason was in the end that this was a private or protected member , so though you could get its value, the isset returned false.
var_dump is problematic as it is doing reflection .
Upvotes: 0
Reputation: 5857
Your probably extending a class with a private member.
See the PHP Examples on how this is treated.
The only way for me to get your output is by using PHPs magic methods on a class, for example:
class A
{
public function __isset($n)
{
$this->$n = TRUE;
}
}
$bar = new A();
var_dump(isset($bar->foo));
var_dump($bar->foo);
Output:
bool(false)
bool(true)
Though I think you'd already knew if you were using one of those.
Upvotes: 2