开发者

What are the performance impacts of declaring variables before <html> tag?

What's the best practice regarding declaring variables at the top of the doc? Is th开发者_如何学Pythonere a performance impact if variable such as $GET or $POST are declared before the html tag?


No, there is no performance impact, why would there be? Your PHP script is completely independent of the HTML code (it is just text for PHP). However, you should really consider separating your coded logic and your HTML code in order to achieve greater maintainability. You can use any php template engine for that purpose.


  1. You don't really declare Superglobals in PHP. PHP populates them for you before your scripts execute.

  2. I presume you mean doing something like $var = $_GET['var'];. You will not be able to measure the negligible amount of time that PHP takes to re-assign the value from the Superglobal to the variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜