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.
You don't really declare Superglobals in PHP. PHP populates them for you before your scripts execute.
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.
精彩评论