View Full Version : Changing HTML

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


// 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 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 id="col-three">
<? include './includes/col-three.php'; ?>


<? include './includes/footer.htm'; ?>

What do i need to do to make these php snippets to execute?

01-24-2010, 06:54 PM
Your server is set-up to run PHP scripts if the file extension is .php (not .html).

You can command the server to process your .html (or .htm) files as PHP by
using the .htaccess file ... if you know what that file is.

Or, simply change the extension of your "index.html" (or whatever) to "index.php".

Look on Google for: http://www.google.com/search?hl=en&rlz=1R2ADFA_enUS351&q=.htaccess+process+.html+as+php&btnG=Search&aq=f&aql=&aqi=&oq=

01-24-2010, 08:14 PM
No the file i run is still a php extension its just i pretty much extract the HTML from a HTML file, change the contents then output it. But it doesnt work by when theres php in the changed HTML code.

01-24-2010, 09:31 PM
It must be missing the <html>, doc-type, and content-type?
Not enough information to determine what it is.

01-24-2010, 09:41 PM
added, but still the same result happens.

01-25-2010, 03:53 AM
I see the word "smarty" ... is this a "smarty" application?
Maybe they take out all <?php coding.

01-25-2010, 07:03 PM
Well, im using the smarty method by which, they replace certain HTML blocks with php and it executes like that, but its not working so well with my script.

01-25-2010, 07:55 PM
I guess that I don't know enough about Smarty to give you a good answer.
maybe someone else will "pipe-in" with something.