所以我不是很擅长 php,我有一个基本的评论系统,我正在尝试实现该系统的调用和写入 comments.php 文件。
一切都很好,直到我尝试对 $outputstring 进行一些样式设置。
这是我的代码
$outputstring = "<br><p><span class="label">Name:</span> " .$name. "</p><br> <p><span class="label">Comment:</span>" .$message. "</p><br>";
我知道是什么原因造成的
<span class="label"></span>
但谁能告诉我为什么?
在我尝试网站建设时,我得到的脚本只是 youtube 上的一个。
完整的脚本是这样的。
<?php
$act = $_POST['act'];
if($act == "post") {
$name = $_POST['name'];
$message = $_POST ['message'];
@$fp = fopen("comments.php", 'a');
if (!$fp) {
//The file could not be opened
echo "There was an error! Please try again later!";
exit;
} else {
//The file was successfully opened, lets write the comment to it.
$outputstring = "<br><p><span class="label">Name:</span> " .$name. "</p><br> <p><span class="label">Comment:</span>" .$message. "</p><br>";
//Write to the file
fwrite($fp, $outputstring, strlen($outputstring));
//We are finished writing, close the file for security / memory management purposes
fclose($fp);
//Post the success message
echo "Your post was successfully entered. Click <a href='index.php'>here</a> to continue.";
}
} else {
//We are not trying to post a comment, show the form.
?>
<h3>comments:</h3>
<hr/>
<?php include("comments.php"); ?>
<br><br>
<h3>Post a comment:</h3>
<form action="index.php" method="post">
<label>Name:<label>
<input type="text" name="name" value=""></input>
<br/>
<label>Comment:</label>
<textarea name="messages"></textarea>
<input type="hidden" name="act" value="post"></input>
<br/>
<input type="submit" name="submit" value="Submit"></input>
</form>
<?php
}
?>
如果有人能告诉我我需要做什么才能添加一个会膨胀的类的跨度。
谢谢。