RE: [PHP] Include Files in HTML
| From: | Joost | Date: | Fri, 04 Sep 2009 21:18:55 +0000 |
| Subject: | RE: [PHP] Include Files in HTML | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297698@lists.php.net to get a copy of this message | ||
"Bob McConnell" wrote:
> From: sono-io at fannullone.us
>
>> In my readings, I've run across examples showing include files
> being
>> called from within the <head></head> tags, and other examples showing
>
>> them called within <body></body>. I've always put them in the header
>
>> section myself, but I was wondering if one is better than the other,
>> or is it just personal preference?
>
> Depends on what you are including. The only tags that can be inside the
> head are <base>, <link>, <meta>, <script>, <style>, and
> <title>.
> Everything else is either body or prologue.
>
> The full specs can be found at
> <http://www.w3schools.com/tags/default.asp>.
>
> Bob McConnell
Sure enough. What the OP might not have realized:
In the end, what PHP evaluates to, is a stream of html, script, css etc
text/data, which is sent to the browser. PHP's include( <file> ) statement
inserts the content of <file> here-and-now. You can even put the include
statement within a for loop in order to include something multiple times...
In that sense it is more like a /function/ and really different from cpp's
#include /directive/.
<file> can contain PHP code, which is evaluated as if it was here-and-now in
the including PHP file; it can contain text/data, which is appended to the
text/data stream being produced.
All in all, to PHP the spot of file inclusion is not interesting, as long as
the resulting PHP code and/or stream data is meaningful.
Now back to you, Bob :-)
Regards,
Joost.