aqeel
09-28-2010, 12:55 PM
hi friends The following code is working fine , but can anyone explain it plz that how this code is working i mean there is no function call how object employee set title as developer how it calls __set(...). Does this mechanism has any specific name in php.
class Employee{
var $name;
function __set($propName,$propValue){
$this->$propName = $propValue;
}
}
$employee = new Employee();
$employee->name = "aqeel";
$employee->title = "Developer";
echo "Name : {$employee->name}";
echo "<br />";
echo "Title : {$employee->title}";
The output is
Name : aqeel
Title : Developer
class Employee{
var $name;
function __set($propName,$propValue){
$this->$propName = $propValue;
}
}
$employee = new Employee();
$employee->name = "aqeel";
$employee->title = "Developer";
echo "Name : {$employee->name}";
echo "<br />";
echo "Title : {$employee->title}";
The output is
Name : aqeel
Title : Developer