Вопрос

If I place PHP code prior to the <html> tag I assume it will be executed prior to the page load. But if I place the same code inside the <body> tag, will the PHP wait for the page load to finish first?

Это было полезно?

Решение 2

The PHP runs, outputting anything outside the <?php ?> tags as it goes.

The output might be buffered and then sent in one go once the script has finished.

The output might be sent bit by bit as the script outputs it.

(Which depends on how the script is written).

If you have <?php foo(); ?> just after <body>, then it will send the body start tag to output, then execute foo, then output whatever follows.

Другие советы

PHP is executed before the page is sent to the client, it doesn't matter where you put your content, PHP will ALWAYS be executed first.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top