<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                :-: 自動加載 ~~~ /** * 類名映射信息 * @var array */ protected static $map = []; /** * 類庫別名 * @var array */ protected static $classAlias = []; /** * PSR-4 * @var array */ private static $prefixLengthsPsr4 = []; private static $prefixDirsPsr4 = []; private static $fallbackDirsPsr4 = []; /** * PSR-0 * @var array */ private static $prefixesPsr0 = []; private static $fallbackDirsPsr0 = []; /** * 自動加載的文件列表 * @var array */ private static $autoloadFiles = []; /** * Composer安裝路徑 * @var string */ private static $composerPath; ~~~ #### 自動加載 ~~~ // 注冊自動加載機制 public static function register($autoload = '') { // 注冊系統自動加載 spl_autoload_register($autoload ?: 'think\\Loader::autoload', true, true); // 注冊命名空間定義 self::addNamespace([ 'think' => __DIR__ . '/', 'traits' => __DIR__ . '/../traits/', ]); $path = dirname($_SERVER['SCRIPT_FILENAME']); if (is_file('./think')) { $rootPath = realpath($path) . '/'; } else { $rootPath = realpath($path . '/../') . '/'; } // 加載類庫映射文件 if (is_file($rootPath . 'runtime/classmap.php')) { self::addClassMap(__include_file($rootPath . 'runtime/classmap.php')); } self::$composerPath = $rootPath . 'vendor/composer/'; // Composer自動加載支持 if (is_dir(self::$composerPath)) { self::registerComposerLoader(self::$composerPath); } // 自動加載extend目錄 self::addAutoLoadDir($rootPath . 'extend'); } // 自動加載 public static function autoload($class) { if (isset(self::$classAlias[$class])) { return class_alias(self::$classAlias[$class], $class); } if ($file = self::findFile($class)) { // Win環境嚴格區分大小寫 if (strpos(PHP_OS, 'WIN') !== false && pathinfo($file, PATHINFO_FILENAME) != pathinfo(realpath($file), PATHINFO_FILENAME)) { return false; } __include_file($file); return true; } } ~~~ [spl_autoload_register](http://php.net/manual/zh/function.spl-autoload-register.php) — 注冊給定的函數作為 __autoload 的實現 ;將函數注冊到SPL __autoload函數隊列中。如果該隊列中的函數尚未激活,則激活它們。 [`pathinfo`](http://www.php.net/pathinfo) — 返回文件路徑的信息 `spl_autoload_register($autoload ?: 'think\\Loader::autoload', true, true);` 自動加載運行了 `autoload` 函數 [`$_SERVER['SCRIPT_FILENAME']`](http://php.net/manual/zh/reserved.variables.server.php)當前執行腳本的絕對路徑。 [realpath](http://php.net/manual/zh/function.realpath.php) — 返回規范化的絕對路徑名;realpath() 擴展所有的符號連接并且處理輸入的 path 中的 '/./', '/../' 以及多余的 '/' 并返回規范化后的絕對路徑名。返回的路徑中沒有符號連接,'/./' 或 '/../' 成分。 `self::addAutoLoadDir($rootPath . 'extend');` 設置 extend 文件目錄為附加配置目錄 ~~~ // 添加Ps0空間 private static function addPsr0($prefix, $paths, $prepend = false) { if (!$prefix) { if ($prepend) { self::$fallbackDirsPsr0 = array_merge( (array) $paths, self::$fallbackDirsPsr0 ); } else { self::$fallbackDirsPsr0 = array_merge( self::$fallbackDirsPsr0, (array) $paths ); } return; } $first = $prefix[0]; if (!isset(self::$prefixesPsr0[$first][$prefix])) { self::$prefixesPsr0[$first][$prefix] = (array) $paths; return; } if ($prepend) { self::$prefixesPsr0[$first][$prefix] = array_merge( (array) $paths, self::$prefixesPsr0[$first][$prefix] ); } else { self::$prefixesPsr0[$first][$prefix] = array_merge( self::$prefixesPsr0[$first][$prefix], (array) $paths ); } } // 添加Psr4空間 private static function addPsr4($prefix, $paths, $prepend = false) { if (!$prefix) { // Register directories for the root namespace. if ($prepend) { self::$fallbackDirsPsr4 = array_merge( (array) $paths, self::$fallbackDirsPsr4 ); } else { self::$fallbackDirsPsr4 = array_merge( self::$fallbackDirsPsr4, (array) $paths ); } } elseif (!isset(self::$prefixDirsPsr4[$prefix])) { // Register directories for a new namespace. $length = strlen($prefix); if ('\\' !== $prefix[$length - 1]) { throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } self::$prefixLengthsPsr4[$prefix[0]][$prefix] = $length; self::$prefixDirsPsr4[$prefix] = (array) $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. self::$prefixDirsPsr4[$prefix] = array_merge( (array) $paths, self::$prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. self::$prefixDirsPsr4[$prefix] = array_merge( self::$prefixDirsPsr4[$prefix], (array) $paths ); } } ~~~ #### 文件加載 ~~~ // 自動加載 public static function autoload($class) { } include 加載文件 ~~~ [`class_alias`](http://php.net/manual/zh/function.class-alias.php) — 為一個類創建別名 `registerComposerLoader($composerPath)` 函數加載 `vendor/composer/` 下的Composer文件 `addAutoLoadDir` 函數加載 `extend` 下的配置文件 因為 使用了 注冊系統自動加載 `spl_autoload_register($autoload ?: 'think\\Loader::autoload', true, true);` 所以 在引用Loader 之后的操作都會自動運行 `autoload` 方法 進行 `PSR` 加載 `think` 目錄下的文件 例如: `A:b(); // 運行think 目錄下 A.php 文件類的 b(); 方法`
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看