Page 1 of 1

PHP within PHP

Posted: Wed Aug 06, 2003 4:02 pm
by ZackKain
I have a slight problem...:

function.php:

Code: Select all

<?php
 function blah($thing) &#123; print "<a href="http://www.$thing.com">$thing</a>"; &#125; 
?>
news.php

Code: Select all

<?php include_once("function.php"); ?>
<p>go to <?php blah("zombo"); ?></p>
home.php

Code: Select all

<?php include_once("function.php"); 
        $display = include 'news_archives.htm';
        $display = explode('</p>', $display);
        for ($i=0;$i<count($display) && $i<4;$i++) print "$display&#1111;$i]</p>";
?>
Outputs code without re-formatting the PHP code. How do I fix this?
Fot the website

Posted: Wed Aug 06, 2003 4:42 pm
by qartis
include() doesn't output the included html, it outputs it directly to the browser. Try to use ob_gzhandler to capture the contents, and then stick 'em in a variable, or in news.php:

Code: Select all

<?php
include_once("function.php");
$output = "<p>go to ". blah("zombo") ."</p>";
?>

And then deal with $output after including news.php :)