, , . , .
private String _name;
public String Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
, :
private $_name;
public function getName()
{
return $_name;
}
public function setName($name)
{
$_name = $name;
}
:
C# : Object.Name = "This is my Name";
PHP : Object->setName ("This is my Name");
# (, , ), , Flosculus - . , , .
:
__set() is run when writing data to inaccessible properties.
__get() is utilized for reading data from inaccessible properties.
furColor , .
, $cat->furColor = 'black.
- furColor , __set .
GetterSetterExample setFurColor , .- , ,
Cat . setFurColor .
, . " " #.
, , ? -, . PHP , , .
- , , , .
, , . Flosculus , () .