Actually i am new to OOPS concepts and it is hard to understand, and i also read it somewhere that "we do not have overloading in PHP".I am studying this example but it didnt get me somewhere.
<?php
class Toys{
private $str;
public function __set($name,$value){
$this->str[$name] = $value;
}
public function __get($name){
echo "Overloaded Property name = " . $this->str[$name] . "<br/>";
}
public function __isset($name){
if(isset($this->str[$name])){
echo "Property \$$name is set.<br/>";
} else {
echo "Property \$$name is not set.<br/>";
}
}
public function __unset($name){
unset($this->str[$name]);
echo "\$$name is unset <br/>";
}
}
$objToys = new Toys;
/* setters and getters on dynamic properties */
$objToys->overloaded_property = "new";
echo $objToys->overloaded_property . "\n\n";
/*Operations with dynamic properties values*/
isset($objToys->overloaded_property);
unset($objToys->overloaded_property);
isset($objToys->overloaded_property);
?>