Read a file, extract and echo some information
| From: | PHP Webmaster | Date: | Mon, 20 Oct 2003 23:35:30 +0000 |
| Subject: | Read a file, extract and echo some information | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-166863@lists.php.net to get a copy of this message | ||
Hi all,
I have a little dilemma on my hands that I can't seem to solve. Iv'e looked
through the PHP Manual at the fread(), fgets(), fopen(), file() etc
functions which I beleive are capabile of what I want to do, but I just
can't seem to peice it all together.
Anyway, the following code is inside of home.php:
<?php
$title = "Home page of the website";
?>
<p>Welcome to the home page of our website.</p>
<p>Blah, blah and more blah!</p>
And the following code is inside of index.php:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php
require("home.php");
?>
</body>
</html>
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.
Any ideas greatly appreciated,
Thanks!