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 red ...
--
PHP General Mailing
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 red ...
--
PHP General Mailing
On Thu, Jul 19, 2012 at 9:22 PM, Sebastian php-maill...@elygor.de 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
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 red
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') {
5 matches
Mail list logo