Reputation: 337
I have a PHP based website and I want to make the code generic by reading the 'keywords' and 'description' metadata from a site specific include file ('META.TXT' say).
I have looked at the < link...> tag but I can't see how to use it to just include text.
I know how to read html content in using Javascript but I don't think that would work for header data.
<header>
<?php
include_once("meta.php");
?>
</header>
I also tried:
<header>
<link rel="???" type="text/css" href="META.TXT">
</header>
What am I missing here?
Upvotes: 0
Views: 667
Reputation: 1836
You had the right idea with your first example. include_once
(as well as include
, require
, require_once
) can be used to non-PHP files as well. Basically, any portion of your included file's content that is not wrapped in PHP tags (<?php
?>
) will be sent to output.
So if your meta tags are in a file called META.TXT (in the same or an accessible path) then they can be included in your header as follows:
<header>
<?php
include_once("META.TXT");
?>
</header>
BTW, if your meta.php file had equivalent echo
statements in it, that should have worked as in your first example also. Perhaps you forgot the <?php
tag in that file.
Upvotes: 2