"Els" <el*********@PLEASEtiscali.nl.invalid> wrote in message
news:bi**********@reader1.tiscali.nl...
If I use <? include "file.html"; ?> in the html of my
document, do I _have_ to change the extension of that
document to .php, or would it still work and be valid if I
let it remain .html?
Apples and oranges. The HTML is valid if the HTML is valid. It's not what
file name your PHP script has. PHP is _server side_ and HTML is the
presentation to the browser _after_ all the server side stuff has happened.
There's not even any reason to ever have a file extension on web content at
all (except to make the files more friendly to applications that pay
attention to the file extension--mostly Win32 stuff). In fact, it's common
practice to create CMS-type scripts with no file extension so the web server
can reference the resource through a friendlier directory-like URI.
By adding that one line of PHP code, you have, in fact, created a
fully-functioning PHP script. This file now requires the HTTP host to
filter it through the PHP parser. On many HTTP hosts, you can set it to
only filter *.php files, or you can set it to filter any combination of
files with a given extension. If your page is working on your server and is
being processed by the PHP parser, it's fine to leave it with the .html
extension. If you ever run into a server that does not run all *.html files
through the parser, your page will not operate correctly until you do one of
two things:
1. Change the extension to "php" or...
2. Change the server's configuration. In Apache, this is as simple as
adding an .htaccess file with one line of configuration (asking to pass
*.html files through the parser). Of course, if you're not in control of
the host, this configuration directive may or may not be allowed to be
controlled in your local web directory.
If this is the extent of your PHP code, I would probably just stick to the
"html" extension. If you get really fancy, it might be more appropriate to
label the thing with a "php" extension so someone else can maintain your
site (I know, it probably won't fall into someone else's hands anyway)
without too much headache.
HTH,
Zac