about class and function __set
Posted: Fri Feb 23, 2007 2:35 am
i am working from Luke Welling and Laura Thomson's book
in the chapter of OOP function __set is explained. as i understand it is important to acces the attributes, and there is an example like this
according to code and my understanding the attribute can't be 110 because we have a if control structure (0>value>100)
but when i run this code it appears 110 on the browser.
is there a fault in code or my understanding
thanks all in advance
in the chapter of OOP function __set is explained. as i understand it is important to acces the attributes, and there is an example like this
Code: Select all
<?php
class class1
{
var $attribute;
function __get($name)
{
$this->$name;
}
function __set($name, $value)
{
if($name=='attribute' && $value >= 0 && $value <= 100)
$this->attribute=$value;
}
}
$a= new class1;
$a->attribute=110;
echo $a->attribute;
?>but when i run this code it appears 110 on the browser.
is there a fault in code or my understanding
thanks all in advance