<!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 "啦啦啦啦";
}
}
浙公网安备 33010602011771号