04-20-2008, 06:43 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Set the visibility to either private or protected. Then to allow reading the value you can use a public method (function) or hook into the __get method.
PHP Code:
class MyClass
{
protected $var;
// ...
public function getVar()
{
return $this->var;
}
// or
public function __get($property)
{
if ($property === 'var')
return $this->var;
}
}
|
|
|
|