The process by which a browser requests a PHP file
test.php
1 <HTML>2 <Head>3 <Metahttp-equiv= "Content-type"content= "text/html"CharSet= "Utf-8">4 </Head>5 <Body>6 <?PHP7 $i = 1 + 2;8 echo "The result is". $i;9 ?>Ten </Body> One </HTML>
1, the browser (http://localhost/test.php) resolves the host name;
2, the host file (127.0.0.1 localhost) query the corresponding IP;
3, if the query is not, jump to the external network DNS;
4. The browser makes an HTTP request to the Apache server
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 parsing host;
6, Apache parsing site/directory;
7, Apache parsing resources (request file) name;
8, Apache request file (test.php);
9, test.php in <?php ...? > code executes on server side, Apache returns results to browser
http/1.1 Okdate:mon, Dec 12:23:55 gmtserver:apache/2.4.23 (Win64) Php/5.6.25x-powered-by:php/5.6.25cont Ent-length:137keep-alive:timeout=5, max=100connection:keep-alivecontent-type:text/html; Charset=utf-8<HTML> <Head> <Metahttp-equiv= "Content-type"content= "text/html"CharSet= "Utf-8"> </Head> <Body>The result is 3.
</Body></HTML>
10, the browser displays the results returned.
Timing Diagram
1, the process of PHP call