Can any one tell what does below given lines means?
The lines below are copied from PHP manual:
Note:
It is not possible to use overloaded properties in other language constructs than isset(). This means if empty() is called on an overloaded property, the overloaded method is not called.
To workaround that limitation, the overloaded property must be copied into a local variable in the scope and then be handed to empty().
BUT this is not true that we cant call empty() on overloaded properties, when i called empty() , it triggered __isset()
It is a documentation bug:
<?php
class PropNameReturn {
function __isset($propname){
return true;
}
function __get($propname){
echo 'Yes, it IS called!'.PHP_EOL;
return $propname;
}
}
$o = new PropNameReturn();
var_dump(empty($o->this_prop_name));
//Yes, it IS called!
//bool(false)
$b = new stdClass();
var_dump(empty($b->this_prop_name));
//bool(true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With