RE: [PHP] Read a file, extract and echo some information
| From: | Chris W. Parker | Date: | Mon, 20 Oct 2003 23:50:02 +0000 |
| Subject: | RE: [PHP] Read a file, extract and echo some information | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-166864@lists.php.net to get a copy of this message | ||
PHP Webmaster <mailto:phpwadmin@phpwebmaster.co.uk>
on Monday, October 20, 2003 4:36 PM said:
> As you can see, the above code will not work as the $title variable
> has not been set yet. So, I need a way of opening up the home.php
> file, extracting the line containing the $title variable and putting
> that information inbetween the <title></title> tags.
In that case do it backwards:
index.php:
<?php
$title = "page title";
include "header.php";
echo "<p>Welcome to the home page of our website.</p>\n"
."<p>Blah, blah and more blah!</p>\n";
include "footer.php";
?>
header.php:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
footer.php:
</body>
</html>
Hope this helps!!
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/