class className{
public $attribute;
function __construct()
{
$this->attribute=123;
} /*function __get($name)
{
echo "__get()done!";
return $this->$name++;
}
*/
//这东西无效?!
function __set($name,$value)
{
echo "__set()done!";
if(($name="attribute")&&($value>=0)&&($value<=100))
$this->$name=$value;
return 1;
}
}$formValue=50000;//if($formValue!=null)
//{
$a=new className();
echo "first".$a->attribute."<br/>";
if($a->attribute=$formValue)
if($a->attribute==$formValue)
echo "设置成功!";
$a->attribute."|";//按理说这样就可以直接输出属性值了,不是么???构造函数是没问题的。
echo "".$a->attribute;
//}
public $attribute;
function __construct()
{
$this->attribute=123;
} /*function __get($name)
{
echo "__get()done!";
return $this->$name++;
}
*/
//这东西无效?!
function __set($name,$value)
{
echo "__set()done!";
if(($name="attribute")&&($value>=0)&&($value<=100))
$this->$name=$value;
return 1;
}
}$formValue=50000;//if($formValue!=null)
//{
$a=new className();
echo "first".$a->attribute."<br/>";
if($a->attribute=$formValue)
if($a->attribute==$formValue)
echo "设置成功!";
$a->attribute."|";//按理说这样就可以直接输出属性值了,不是么???构造函数是没问题的。
echo "".$a->attribute;
//}
<?php
class className{
public $attribute;
function __construct()
{
$this->attribute=123;
} /*function __get($name)
{
echo "__get()done!";
return $this->$name++;
}
*/
//这东西无效?!
function __set($name,$value)
{
echo "__set()done!";
// if(($name="attribute")&&($value>=0)&&($value<=100))
$this->$name=$value;
return 1;
}
} $formValue=50;
$a=new className();
echo "first".$a->attribute."<br/>";
if($a->attribute=$formValue)
if($a->attribute==$formValue) echo "设置成功!"; $a->attribute."|";
echo "".$a->attribute; $a->a = 40;
echo $a->a;