页次: 1
有个函数是
function __autoload($class) { if (is_file($file."php")) { require_once($file."php"); } }
当示例一个类的时候, 这个类不存在,这个函数就会执行。
spl_autoload_register 相当于自定义一个 __autoload
<?php header("Content-type:text/html;charset=utf-8"); function load_class() { echo "这里要加载类"; die(); } spl_autoload_register('load_class'); $x = new xxx222_not_eixts();
输出
这里要加载类
ipbbs.net
离线
页次: 1