kakingho 0 Report post Posted April 23, 2006 test.php <?php$abc='123';include 'index.htm';?> index.htm<table width="200" border="1"> <tr> <td>$abc</td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> it shows this pichttp://i19.photobucket.com/albums/b190/kakingho/abc.jpgbut i want to show thishttp://i19.photobucket.com/albums/b190/kakingho/123.jpgi want to separate main php codes in php file and main website structure in htm file~how to do that?!i dont want to type this in htm file, any other method?? <table width="200" border="1"> <tr> <td><?PHP $abc; ?></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> thx~ Notice from BuffaloHELP: Please limit your picture's width to no more than 640px Share this post Link to post Share on other sites
Inspiron 0 Report post Posted April 23, 2006 You've actually answered for yourself.This code <td><?PHP $abc; ?></td>or this code<td><?php echo $abc; ?></td>will work similarly.Unfortunately, you have to do this to obtain the content of the variable $abc. There are no other ways because HTML cannot take non-HTML codes. The server does not understand $abc and hence treated it as plain text to display on a normal HTML page. Inserting PHP code tags and changing the file type to PHP will print the correct information as they stated the correct scripting.Likewise you cannot have javascript contents without declaring it's a javascript.<script language="javascript"> Share this post Link to post Share on other sites
Spectre 0 Report post Posted April 26, 2006 Alternatively, you could simply get the contents of the file, and replace the said string with the variable's value, something like: <?php$abc='123';echo str_replace('$abc',$abc,file_get_contents('index.htm'));?> You may want to check out the Smarty template engine; it's very easy to use and works wonderfully, and operates on a similar premises to this. You simply add the variable in the template along the lines of {$VARIABLE}, and Smarty automatically replaces it with the assigned value ($smarty->assign('VARIABLE','value') when displaying it. Anyway, PHP is not going to process any data outside of the <? ?> tags (usually <?php ?>, but not always). Which means that you are going to explicitly instruct it to output the said variable. Share this post Link to post Share on other sites