Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
backend
php
oop
classes_objects
77overload_prop.php
77overload_prop.php
<?php class Toys{ private $niz; public function __set($key,$val){ $this->niz[$key] = $val; } public function __get($key){ echo "Overloaded Property value = " . $this->niz[$key] . "<br/>"; } public function __isset($key){ if(isset($this->niz[$key])){ echo "Property \$$key is set.<br/>"; } else { echo "Property \$$key is not set.<br/>"; } } public function __unset($key){ unset($this->niz[$key]); echo "\$$key is unset <br/>"; } } $objToys = new Toys; $objToys->overloaded_property = "novo"; //poziva __set $objToys->overloaded_property; //poziva __get isset($objToys->overloaded_property); //poziva __isset unset($objToys->overloaded_property); //poziva __unset isset($objToys->overloaded_property); //poziva __isset ?>
Reload page
Preview
W3C validation
Edit Code