Re: Read a file, extract and echo some information

From: Date: Tue, 21 Oct 2003 11:17:10 +0000
Subject: Re: Read a file, extract and echo some information
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166930@lists.php.net to get a copy of this message
"Chris W. Parker" <cparker@swatgear.com> wrote in message news:001BD19C96E6E64E8750D72C2EA0ECEE2B81AA@ati-ex-01.ati.local... 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/ The above would work OK, but in the index.php file, where I have: <?php require("home.php"); ?> The required file will be changing all the time, that's why I want to set the title in the individual pages and get the main page to read that information.

« previous php.general (#166930) next »