Killermud
01-24-2010, 05:26 PM
Hi there, i have problem in which im designing a system that will include a HTML file and then replace some of HTML with PHP and then output. But Im having a problem where the PHP i replaced does not execute instead it shows up in the HTML itself.
So here is the code that does the work :
function compile($file){
// uses smarty method
$outfile=file_get_contents($file);
// remove all include tags
preg_match('<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+) -->', $outfile, $this->match);
$code=preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+) -->#', $this->wrap_php($this->exchange_include('$1')), $outfile);
return $code;
}
But it only outputs the following HTML :
<body onload="preloadImages();">
<div id="wrapper">
<?php include('./includes/header.php'); ?>
<div id="col-one">
<?php include('./includes/col-one.php'); ?>
</div>
<div id="col-two">
<?php include('adcol'); ?>
<?php include('recentcol'); ?>
<div class="mainboxed">
<h2 class="title" onclick="showHideDiv('news')"><img src="images/arrow_down.png" border="0" class="collapsearrow" /><? echo $rows['blog_title']; ?></h2>
<div class="content" id="news">
<p><img src="./images/css.jpg" class="newslogo">Posted by <a href="view_member.php?id=<? echo $uid; ?>" class="admin"><? echo $rows['blog_author']; ?></a> on <? echo $time; ?></p><br>
<p><? echo BBCode($rows['blog_detail']); ?>
</p><div style="clear:both;"></div>
<br><p class="comments"><a href="newspost.html">Replies (2)</a> <a href="#" class="buttonfake">Reply</a></p>
</div>
</div>
</div>
<div id="col-three">
<? include './includes/col-three.php'; ?>
</div>
</div>
<? include './includes/footer.htm'; ?>
</body>
What do i need to do to make these php snippets to execute?
So here is the code that does the work :
function compile($file){
// uses smarty method
$outfile=file_get_contents($file);
// remove all include tags
preg_match('<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+) -->', $outfile, $this->match);
$code=preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+) -->#', $this->wrap_php($this->exchange_include('$1')), $outfile);
return $code;
}
But it only outputs the following HTML :
<body onload="preloadImages();">
<div id="wrapper">
<?php include('./includes/header.php'); ?>
<div id="col-one">
<?php include('./includes/col-one.php'); ?>
</div>
<div id="col-two">
<?php include('adcol'); ?>
<?php include('recentcol'); ?>
<div class="mainboxed">
<h2 class="title" onclick="showHideDiv('news')"><img src="images/arrow_down.png" border="0" class="collapsearrow" /><? echo $rows['blog_title']; ?></h2>
<div class="content" id="news">
<p><img src="./images/css.jpg" class="newslogo">Posted by <a href="view_member.php?id=<? echo $uid; ?>" class="admin"><? echo $rows['blog_author']; ?></a> on <? echo $time; ?></p><br>
<p><? echo BBCode($rows['blog_detail']); ?>
</p><div style="clear:both;"></div>
<br><p class="comments"><a href="newspost.html">Replies (2)</a> <a href="#" class="buttonfake">Reply</a></p>
</div>
</div>
</div>
<div id="col-three">
<? include './includes/col-three.php'; ?>
</div>
</div>
<? include './includes/footer.htm'; ?>
</body>
What do i need to do to make these php snippets to execute?