首页 > 其他 > 详细

魔术方法

时间:2017-08-27 11:46:03      阅读:197      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php
/*class Ren{
	public $name;
	
	public function __tostring(){
		return "这是Ren类,有成员变量name代表名称";
	}
	//当克隆对象的时候,自动调用
	public function __clone(){
		$this->name = "李四";//$this代表副本
	}
}
$r = new Ren();
$r->name = "张三";
//echo $r; //自动调用tostring方法
var_dump($r);

$r1 = clone $r;
var_dump($r1);*/

//加载类
//include("./test.class.php");
//include "./test.class.php";
//include_once("./test.class.php");//当前页面只加载一次

//require("./test.class.php");
//require "./test.class.php";
//require_once("./test.class.php");

//自动加载类
//1.类名必须和文件名保持一致
//2.所有类的命名规则一致
//3.所有类必须在同一文件夹下
/*function __autoload($cname){
	
}*/

/*$t = test();
$t->ceshi();*/



?>
</body>
</html>

  引用:

<?php
class test{
	public $name;
	public function ceshi(){
		echo "啦啦啦啦";
	}
}

  

魔术方法

原文:http://www.cnblogs.com/sglq/p/7439800.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!