【发布时间】:2015-01-26 19:17:09
【问题描述】:
我知道我会因此而被否决,但我需要问一下。下面的代码是什么意思?具体来说, 我很困惑
if (empty($_POST["comment"])) { $comment = "";
这是否意味着如果用户没有插入他的 cmets,那么值为 "$comment" 的字段将是空白的?如果用户插入了评论,那么值“$comment”将通过 test_input 函数输入?我看过 w3schools 网站,但我并不聪明。令人难以置信的是,没有网站甚至描述了 test_input 所做的事情,相信我,我看过几十个网站。事实上,我并不是唯一一个认为 test_input 是一个神秘函数的 SO 用户。
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo 'posted';
if (empty($_POST["comment"])) {
$comment = "";
} else {
$comment = test_input($_POST["comment"]);
}
【问题讨论】:
-
是的,就是这个意思。
-
"如果发布的
comment字段是empty,则将$comment设置为空字符串。但是,如果它不为空,则将$comment设置为结果以注释为参数的test_input函数"test_input很可能是您的 PHP 代码中使用function test_input定义的某个函数。 -
这个问题似乎跑题了,因为“test_input()”不是一个php函数。