面向对象--加载类

//加载类

根据绝对路径加载,根据相对路径加载

//include ("/wamp/www/ren.class.php");---"/"根路径,php中指该文件所在的磁盘,html中指服务器文件夹:www。
//include "ren.class.php";

//require("/wamp/www/ren.class.php");
//require "ren.class.php";

//require_once("/wamp/www/Ren.class.php");//只加载一次
//require_once "Ren.class.php";

//require方法和include方法的区别
//前者一般写在顶部,如果引用出错,那么终止程序、后者如果引用出错,下面的程序依然执行。

//自动加载类---适用于加载多个类,所有类必须在同一个文件夹下
function __autoload($classname)
{
require $classname.".class.php";
}
$r=new ren();

原文地址:https://www.cnblogs.com/jinshui/p/5569615.html