PHP within PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ZackKain
Forum Newbie
Posts: 1
Joined: Wed Aug 06, 2003 4:02 pm

PHP within PHP

Post 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
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post 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 :)
Post Reply