Ejemplo n.º 1
0
 public function __destruct()
 {
     Stat::getInstance();
     new Error();
 }
Ejemplo n.º 2
0
<?php

ini_set('display_errors', "On");
error_reporting(E_ALL | E_STRICT);
//自动加载类
set_include_path(get_include_path() . PATH_SEPARATOR . 'class/');
//设置加载路径
spl_autoload_extensions('.php');
//设置加载后缀名
function myAutoload($className)
{
    require_once $className . '.php';
    //直接根据类名跟文件关系包含文件
}
spl_autoload_register("myAutoload");
//注册自动加载函数
//测试代码开始
echo Stat::getInstance()->sayHi();
echo '<br>';
echo Teacher::getInstance()->sayHi();
echo '<br>';
class People
{
    function sayHi()
    {
        return 'Hello i am a people?';
    }
}
echo Singleton::getInstance('People')->sayHi();
echo '<hr>';
echo file_get_contents('./read.txt');