order of execution in web environment

2020-02-14 07:41发布

what is the order of execution in web ? PHP, HTML, Javascript, css and mysql are the items to execute

7条回答
Melony?
2楼-- · 2020-02-14 08:06

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.

查看更多
太酷不给撩
3楼-- · 2020-02-14 08:09

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)

查看更多
贼婆χ
4楼-- · 2020-02-14 08:12

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.

查看更多
你好瞎i
5楼-- · 2020-02-14 08:18

The order is like this:

  • Browser - send request
  • Server - execute PHP script
  • Server - send output to browser
  • Browser - read output and execute JavaScript

Here is an example:

  • Browser: requesting page /index.php
  • Server: execute index.php file on the server

    <?php echo "Hello, world!;"; ?> <script>alert("hello!")</script>

  • Server: respond the output

  • Browser: parse the output
  • Browser: <script> detected, alert("hello!")

查看更多
闹够了就滚
6楼-- · 2020-02-14 08:25

That depends on what order everything is on the page top to bottom.

查看更多
爷的心禁止访问
7楼-- · 2020-02-14 08:26

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

查看更多
登录 后发表回答