Re: Processing PHP in Template File

From: Date: Thu, 12 Sep 2002 19:42:27 +0000
Subject: Re: Processing PHP in Template File
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116195@lists.php.net to get a copy of this message
John Include your template this way: $file_name="templates/somefile.php" $New_Content1 = 'This is the new text'; $New_Content2 = 'This is the other text'; include $file_name; In the template file, have <?php echo $New_Content; ?> etc wherever the content should appear. Then you can put other php code in the template file as well. I use this all the time. Peter At 12:00 PM 9/12/2002 -0700, you wrote:
Hello everyone. I want to implement templates in a site, but am having trouble processing php within the template file. The application flow is as follow: -open the template file (which has some place holders) with $fileHandler = file($file_name) -Replace placeholders (within the template files) with $fileHandler = ereg_replace("--PlaceHolder--","New content",$Handler) //disregard syntax errors... -Then display the content of the modified template $fileHandler = implode('',$fileHandler) echo $fileHandler; The above process works, as far as replace the place holders, and printing the new content (which is an HTML file). However, it will not process PHP scripts, within the template. For example, if my template has ...... <?php> echo "hello!"; ?> blah blah blah the above process will display the PHP code within the HTML file, without processing. How can I process the PHP codes that's in the template? -john =P e p i e D e s i g n s www.pepiedesigns.com Providing Solutions That Increase Productivity Web Developement. Database. Hosting. Multimedia. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- - - - - - - - - - - - - - - - - - - - - Fourth Realm Solutions pbechard@fourthrealm.com http://www.fourthrealm.com Tel: 519-739-1652 - - - - - - - - - - - - - - - - - - - - -

« previous php.general (#116195) next »