<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國際加速解決方案。 廣告
                PHP 5.4起就在CLI SAPI中內置了web服務器,但只是提供開發測試使用,不推薦使用中生產環境中。因為這個服務器接受處理請求時順序執行的,不能并發處理。 這個內置的web服務器使用起來非常的方便,你只需要執行下面的命令: ## 啟動Web服務器 ``` $ php -S localhost:8000 ``` 然后就可以訪問了。這樣啟動后,默認的web服務目錄是執行命令的當前目錄,如果不想使用當前目錄,你需要使用 -t 參數來指定。 ## 啟動web服務器時指定文檔的根目錄 ``` php -S localhost:8000 -t foo/ ``` ## 使用路由器腳本 在這個例子中,對圖片的請求會返回相應的圖片,但對HTML文件的請求會顯示“Welcome to PHP”: ```php // router.php if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) { return false; // serve the requested resource as-is. } else { echo "<p>Welcome to PHP</p>"; } ``` ``` $ php -S localhost:8000 router.php ``` ## 判斷是否是在使用內置web服務器 通過程序判斷來調整同一個PHP路由器腳本在內置Web服務器中和在生產服務器中的不同行為: ```php // router.php if (php_sapi_name() == 'cli-server') { /* route static assets and return false */ } /* go on with normal index.php operations */ ``` ``` $ php -S localhost:8000 router.php ``` 這個內置的web服務器能識別一些標準的MIME類型資源,它們的擴展有:.css, .gif, .htm, .html, .jpe, .jpeg, .jpg, .js, .png, .svg, and .txt。對.htm 和 .svg 擴展到支持是在PHP 5.4.4之后才支持的。 ## 處理不支持的文件類型 如果你希望這個Web服務器能夠正確的處理不被支持的MIME文件類型,這樣做: ```php // router.php $path = pathinfo($_SERVER["SCRIPT_FILENAME"]); if ($path["extension"] == "ogg") { header("Content-Type: video/ogg"); readfile($_SERVER["SCRIPT_FILENAME"]); } else { return FALSE; } ``` ``` $ php -S localhost:8000 router.php ``` ## 遠程訪問這個內置Web服務器 如果你希望能遠程的訪問這個內置的web服務器,你的啟動命令需要改成下面這樣: ``` $ php -S 0.0.0.0:8000 ``` 這樣你就可以通過 8000 端口遠程的訪問這個內置的web服務器了
                  <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>

                              哎呀哎呀视频在线观看