Page 1 of 1
php include and html??
Posted: Fri Mar 07, 2008 9:05 pm
by josh22x
I am trying to use the php include statement in some html content. I am sorta confused about it.
When using the include statement, does the included file need to be a php file or can it be an html file?
Also where do I include the include statement in the html document? In the header?
Thanks
Josh
Re: php include and html??
Posted: Fri Mar 07, 2008 9:40 pm
by Christopher
You can include either PHP or HTML files (or any other kind). But only the code between the <?php and ?> will be executed by PHP. So if the file has not PHP then nothing is executed and the contents are sent to the browser.
Re: php include and html??
Posted: Sat Mar 08, 2008 1:19 pm
by josh22x
So the content in my included file is just some hyperlinks that are contained in the menu section of my page like:
<li><a href="http://www.blabla.com">text</a></li>
<li><a href="http://www.blabla.com">text</a></li>
<li><a href="http://www.blabla.com">text</a></li>
<li><a href="http://www.blabla.com">text</a></li>
<li><a href="http://www.blabla.com">text</a></li>
That is all that is in the lincluded html file, no other tags, but it is not working. What am I doing wrong?
Thanks
Josh
Re: php include and html??
Posted: Sat Mar 08, 2008 1:28 pm
by bertfour
If the links above are in "links.html" you should have:
Somewhere in your php file.....
Re: php include and html??
Posted: Sun Mar 09, 2008 2:59 pm
by josh22x
I think I might have figured it out:
The file with the include tag within it has be be something.php, not something.html in order for it to work.
Is that a correct assumption?
Thanks!
Josh
Re: php include and html??
Posted: Sun Mar 09, 2008 3:15 pm
by Christopher
Yes. But understand that is a web server setting. Usually web servers are configured to parse files with the extension .php as PHP scripts, but you could also configure your webserver to have .html or .xyz files parsed by PHP as well.