前台如何输出保存到数据库的php代码

naner_china 2010-12-07 06:24:07
我想实现功能: 调用数据库中php 变量值 并显示在前台
比如变量定义 define('PUBLIC_VAR_CO', 'xxxxx');

数据库保存值:<tr bgcolor="#eaeaea">
<table>
<tbody>
<td><span class="item_boldtext">Test:</span></td>
<td><span class="item_normaltext">
<?php echo PUBLIC_VAR_CO;?>
</span></td>
</tr>
</tbody>
</table>

前台输出为:
<tr bgcolor="#ffffff">
<td><span class="item_boldtext">Test:</span></td>
<td><span class="item_normaltext">
<!--?php echo PUBLIC_VAR_CO;?-->
</span></td>
</tr>

请问各位大虾,要如何实现或其它简单方法这个功能
...全文
142 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
在-云端 2010-12-07
  • 打赏
  • 举报
回复

$str = "xxxxxxxxxxxxxxxxxxxxxxxx";//数据库读出的数据
$str = str_replace("?>","?-->",str_replace("<?","<!--?",str_replace("PUBLIC_VAR_CO",PUBLIC_VAR_CO,$str)));

echo($str);


21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧