我有一个带有textarea控件的表单,主要用于输入由纯文本组成的文章...在textarea控件中,我有像
这样的文本
我提交表单并将textarea数据保存到数据库字段中。到目前为止一直很好..
在浏览器中,我正在尝试输出数据库字段,但我没有得到php包含文件的内容,而是得到类似以下内容:
php标签被评论!!!
为什么浏览器没有显示/解析包含文件的内容?
更新: 这是test.php的内容
<?php
echo test;
?>
这是article.php的代码
<?php
require_once('../includes/global.inc.php');
require_once('../includes/connection.inc.php');
if (isset($_GET['article']) && is_numeric($_GET['article'])) {
$get_article = (int)$_GET['article'];
$conn = connect('read');
$sql = 'SELECT article.article_id, article.title, article.description, article.article, article.seo_url
FROM article
WHERE article.article_id = ?';
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param('i', $get_article);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($articleid, $title, $description, $article, $seourl);
$stmt->fetch();
$stmt->free_result();
$stmt->close();
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body>
<?php
echo $title;
echo $article;
?>
</body>
</html>
答案 0 :(得分:2)
好像你误解了PHP的执行地点。 PHP在服务器上执行,而不是在浏览器中执行。您必须确保PHP将在服务器上解析该站点。您通常会使用支持PHP的Web服务器并为该文件提供.php扩展名。
php代码没有被注释掉。这只是你的调试工具,它显示它已经过评论,因为开放<?php
会导致无效的HTML。您的浏览器的HTML解析器也可能添加<!--
以避免打开php的问题。我完全不知道。
你可以通过查看原始html源代码来验证这一点,你会发现没有魔法可以注释你的php:)