On a single page, I am testing the ability to store HTML and PHP code in a print statement within a user-defined function, then execute that function.
My problem is that I cannot get opening and closing PHP tags ( <? , ?> ) to be stored in a string. So when the function is executed, it gets confused when it sees <? and ?> within PHP code. If I take those out, then the function prints the information like html code, leaving a nasty mess of unused PHP code visible on the webpage.
Code: Select all
<? function foo () { print '
<table>
<tr>
<td><b>Items</b></td>
</tr>
// here i would like to have the function print " <? "
if ($sailboat)
{ print "
<tr>
<td><li><font color=gray>ї$sailboat] sail boat</font></td>
</tr>
"; }
// here i would like to have the function print " ?> "
</table>
'; } ; ?>
<?
foo();
mysql_close($conn);
?>