您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
命名空间和虚拟主机搭建
发布时间:2019-09-06 21:30:54编辑:雪饮阅读()
对象索引
有脚本如:
<?php
class a{
}
class c{
}
$a=new a();
$b=new a();
$c=new c();
var_dump($a);
var_dump($b);
魔术方法__autoload在命名空间中的妙用
假定我为我的class文件进行了目录归类,其中有一个a目录下放了n多class,其中有一个b的类,如:
b.php
<?php
namespace a;
class b{
}
?>
而与a目录同级有a.php如:
<?php
function __autoload($calssName){
$calssName=str_replace('\\','/',$calssName);
$path=$calssName.".php";
if(file_exists($path)){
include $path;
}
else{
echo $path." not found";
}
}
var_dump($c);
?>
则有对象索引如:
关键字词:命名空间,__autoload,魔术方法
上一篇:http协议模拟发送