克隆及加载类

class Ren{
public $name;
public function __tostring(){
}
public function __clone(){
$this->name = "里斯";
}
}
克隆对象
$r = new Ren();
$r->name = "张三";
$r1 = clone $r;
加载类
include("./ceshi.php");使用once,防止写多了,
include_once("./ceshi.php");相对路径找到同级文件夹下,只拿一次
require("./ceshi.php");
require "./ceshi.php";
require_once ("./ceshi.php");
include和require的区别
自动加载
1类的命名要规范,类名.class.php
2所有的类要放在同一文件夹下
function __autoload($classname){
require_once "./lib/{$classname}.class.php";
}

原文地址:https://www.cnblogs.com/forqiwen/p/8258362.html