PHP 8.5.0 Released!

Voting

: min(six, four)?
(Example: nine)

The Note You're Voting On

gabe at fijiwebdesign dot com
11 years ago
Note that you can enable "overloading" on a class instance at runtime for an existing property by unset()ing that property. 

eg: 

<?php
class Test { 

    public $property1;

    public function __get($name) 
    {
        return "Get called for " . get_class($this) . "->\$$name \n";
    }

}
?>

The public property $property1 can be unset() so that it can be dynamically handled via __get(). 

<?php 
$Test = new Test();
unset($Test->property1); // enable overloading
echo $Test->property1; // Get called for Test->$property1
?>

Useful if you want to proxy or lazy load properties yet want to have documentation and visibility in the code and debugging compared to __get(), __isset(), __set() on non-existent inaccessible properties.

<< Back to user notes page

To Top