美容营销型网站,图片外链在线生成,聊天软件开发哪个好点,桌面百度目录 1、设置常量并绑定容器
2、容器增加设置当前容器的实例和绑定一个类实例当容器
3、将常量绑定到容器中
4、运行效果 1、设置常量并绑定容器 2、容器增加设置当前容器的实例和绑定一个类实例当容器 //设置当前容器的实例public static function setInstance($instance){…目录 1、设置常量并绑定容器
2、容器增加设置当前容器的实例和绑定一个类实例当容器
3、将常量绑定到容器中
4、运行效果 1、设置常量并绑定容器 2、容器增加设置当前容器的实例和绑定一个类实例当容器 //设置当前容器的实例public static function setInstance($instance){static::$instance $instance;}//绑定一个类实例当容器public function bandInstance($abstract, $instance){if ($instance instanceof \Closure) {$this-bind[$abstract] $instance;} else {if (isset($this-bind[$abstract])) {$abstract $this-bind[$abstract];}$this-instances[$abstract] $instance;}return $this;}3、将常量绑定到容器中
?php
namespace fm;
class core extends Di{protected $corePath;//核心目录路径protected $rootPath;//项目根目录public function __construct($appPath ){}public function run(){$this-_int();//初始化常量echo 框架运行中;}public function _int(){//获取框架核心路径 都替换/以便兼容linux$pathstr_replace(\\,/,__FILE__);//定义常量$this-corePathdirname(dirname($path));$this-rootPathdirname($this-corePath);static::setInstance($this);$this-bandInstance(core, $this);var_dump( $this-getInstance());exit;}}
4、运行效果