【发布时间】:2009-07-01 12:29:25
【问题描述】:
topic.php
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$query = mysql_query("SELECT * FROM topics WHERE id = $id");
$row = mysql_fetch_assoc($query);
$title = htmlspecialchars($row['title']);
$text = bbcode($row['text']);
查看/topic.php
<h1><?=$title?></h1>
<p><?=$text?></p>
<h1>Replies</h1>
$q = mysql_query("SELECT * FROM replies WHERE topic_id = $id");
while ($r = mysql_fetch_array($q)) {
$text = bbcode($r['text']);
$date = $r['date'];
$poster = $r['poster'];
$edited = $r['edited'];
echo "<p>$text</p>";.......
}
如您所见,我在 view/topic.php 中有一些丑陋的代码。我可以以某种方式将它保存在 topic.php 中吗?网页设计师不得不处理这一切并不好玩。
谢谢!
【问题讨论】:
-
你能澄清你想要什么吗?您是否希望代码仅存在于一个地方?
-
是的,没错,我想将代码保存在 1 个文件中
-
我没有打开 register_globals,刚刚检查过