所以我不是那么伟大的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
}
?>
如果任何人可以告诉我,我需要做什么才能够添加一个类将会膨胀的跨度。
谢谢。
您需要使用'\“'转义引号,或者使用单引号:'或'' – billyonecan
'或者使用单引号 – Raptor