what is the order of execution in web ? PHP, HTML, Javascript, css and mysql are the items to execute
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- Laravel Option Select - Default Issue
- How to toggle on Order in ReactJS
- PHP Recursively File Folder Scan Sorted by Modific
I can only recommand you a lot to view this talk by Steve Souders on JSConf : http://jsconfeu.blip.tv/file/3060565/
He talked about to best practices to optimise loading of your page on client side.
On the server side, you should know PHP stop execution until it get response from MySQL.
Anything server side will run, then anything client side will run (in the order it appears, although note that running some bits of code just sets up an event handler that contains code that will run when the event actually happens)
Order of execution (When you first visit a page):
Server-side first, then client-side.
Web server handles request, then begins execution of server-side scripts.
PHP is server-side, so it'll execute first. Your using PHP to execute mysql queries and get data out of tables, correct? So during the execution of your PHP script(s), your mysql queries will execute. Then, when your PHP has finished executing, your client-side elements (HTML, Javascript, css) will get executed/be interpreted.
The order is like this:
Here is an example:
Server: execute index.php file on the server
<?php echo "Hello, world!;"; ?> <script>alert("hello!")</script>
Server: respond the output
<script>
detected,alert("hello!")
That depends on what order everything is on the page top to bottom.
User makes a request -> handled by your web server (probably apache) -> handed off to php -> php builds html using mysql and returns it -> html is interpreted, and references css -> javascript executes on the client