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
php include and html??
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: php include and html??
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.
(#10850)
Re: php include and html??
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
<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??
If the links above are in "links.html" you should have:
Somewhere in your php file.....
Code: Select all
<?
include('links.html');
?>
Re: php include and html??
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
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
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: php include and html??
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.
(#10850)