If you want to block setting of public properties on your class, implement
the magic setter.
class Foo {
private $data = array();
function __get($name) {
return $this->data[$name];
}
function __set($name, $value) {
if ($name != 'foo') {
On 07/19/2012 12:22 PM, Sebastian wrote:
Hi all,
is this a bug, or a feature?
class Foo
{
private $data;
public function __get($name)
{
return $this->data[$name];
}
}
$foo = new Foo();
$foo->color = 'red';
echo $foo->color;
I would expect an error, or a least a notice, but it prints out "re
On Thu, Jul 19, 2012 at 9:22 PM, Sebastian wrote:
> Hi all,
>
> is this a bug, or a feature?
>
> class Foo
> {
> private $data;
>
> public function __get($name)
> {
> return $this->data[$name];
> }
> }
>
> $foo = new Foo();
> $foo->color = 'red';
>
> echo $foo->color;
>
> I would expec
3 matches
Mail list logo