1、php的調用過程

來源:互聯網
上載者:User

標籤:http   str   local   log   mil   src   技術分享   text   power   

瀏覽器請求一個php檔案的流程

test.php

 1 <html> 2     <head> 3         <meta http-equiv="content-type" content="text/html" charset="utf-8"> 4     </head> 5     <body> 6     <?php 7         $i = 1 + 2; 8         echo "結果是".$i; 9     ?>10     </body>11 </html>

1、瀏覽器(http://localhost/test.php)解析主機名稱;

2、向HOST檔案(127.0.0.1 localhost)查詢主機對應的IP;

3、如果查詢不到,跳到外網DNS;

4、瀏覽器向Apache伺服器發出http請求

GET http://127.0.0.1/test.php HTTP/1.1Host: 127.0.0.1User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36Accept: */*Accept-Encoding: gzip, deflate, sdch, brAccept-Language: zh-CN,zh;q=0.8

5、Apache解析主機;

6、Apache解析網站/目錄;

7、Apache解析資源(請求檔案)名;

8、Apache請求檔案(test.php);

9、test.php中<?php ……?>代碼在伺服器端執行,Apache返回結果給瀏覽器

HTTP/1.1 200 OKDate: Mon, 12 Dec 2016 12:23:55 GMTServer: Apache/2.4.23 (Win64) PHP/5.6.25X-Powered-By: PHP/5.6.25Content-Length: 137Keep-Alive: timeout=5, max=100Connection: Keep-AliveContent-Type: text/html; charset=UTF-8<html>    <head>        <meta http-equiv="content-type" content="text/html" charset="utf-8">    </head>    <body>        結果是3 
</body></html>

10、瀏覽器顯示返回結果。

時序圖

1、php的調用過程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.