<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 2.2 類自動加載 ~~~ 1. 在啟動文件中新建一個load()方法 2. 舉例:新建一個路由類 3. spl_autoload_register 注冊給定的函數作為` __autoload` 的實現 4. 自動加載實現 5. 啟動框架 ~~~ ### 1. 在啟動文件中新建一個`load()`方法 * * * * * *D:\wamp\www\web.com\core\thinkphp.php* ~~~ // 自由加載類庫 static public function load($class) { // } ~~~ ### 2. 舉例:新建一個路由類 *D:\wamp\www\web.com\core\route.php* ~~~ <?php namespace core; class route { public function __construct() { echo "路由初始化成功"; } } ~~~ ### 3. `spl_autoload_register` 注冊給定的函數作為` __autoload` 的實現 [spl_autoload_register](http://php.net/manual/zh/function.spl-autoload-register.php) 注冊給定的函數作為 __autoload 的實現 ~~~ //class 未能加載的 spl_autoload_register() <?php namespace Foobar; class Foo { static public function test($name) { print '[['. $name .']]'; } } spl_autoload_register(__NAMESPACE__ .'\Foo::test'); // 自 PHP 5.3.0 起 new InexistentClass; ?> ~~~ ### 4. 自動加載實現 ~~~ static public function load($class) { if (isset($classMap[$class])) { return true; } else { // p($class); $class = str_replace('\\', '/', $class); $file = THINKPHP . '/' . $class . '.php'; // p($file); if (is_file($file)) { include $file; self::$classMap[$class] = $class; } else { return false; } } } ~~~ ### 5. 啟動框架 *D:\wamp\www\web.com\index.php* ~~~ ...... // 實現自動加載 spl_autoload_register('\core\thinkphp::load'); \core\thinkphp::run(); ~~~ ### 效果 ![](https://box.kancloud.cn/3da3f3a0cbe303ae7d4665c03ebd633b_952x607.png)
                  <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>

                              哎呀哎呀视频在线观看