php面向对象

发布时间:2014-07-23 12:43:00 阅读:1111次

转:http://www.cnblogs.com/52php/p/5658145.html

http://php.net/manual/zh/language.oop5.php

<?php

class myclass{
public $username;
private $sex;
function __construct(){
$this->username="victor";
$this->sex="男";
echo "class start<br>";
}
function __destruct(){
echo "<br>class end";
}

function __call($func_name,$func_param){
echo $func_name." is not exist<br>";
print_r($func_param);
echo "<br>";
}

function read_var(){
return $this->username;
}

function test($name,$age){
return $name."=".$age;
}

function __get($param_name){
echo $param_name ." is not exist";
if(isset($this->$param_name))
{
return($this->$param_name);
}else
{
return(NULL);
}
}

function get_sex(){
return $this->sex;
}

function __set($key,$value){
#echo "1".$key;
#echo "2".$value;
$this->$key=$value;
return $this->$key;
}

}
$test=new myclass();
$test->mytest("victor","29");
echo $test->test("yansiyu","29");
echo "<br>";
echo $test->read_var();
echo "<br>";
echo $test->username;
echo "<br>";
echo $test->age;
echo "<br>";
echo $test->get_sex();
echo "<br>";
$test->sex="女";
echo $test->sex;
echo "!";
?>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
上一篇:php中使用ftp

转载请注明:php面向对象 出自老鄢博客 | 欢迎分享