-4
$citylink_view = "view=$targetview&postevent=$_GET[postevent]";

它显示未定义的索引:postevent。我通过使用解决了它

$posteventview = $_GET['postevent'];
$citylink_view = "view=$targetview&".$posteventview;

但这在我的 URL 中产生了问题。功能不起作用....

4

1 回答 1

1

之前的情况:

$citylink_view = "view=$targetview&postevent=$_GET[postevent]";

这与以下内容相同:

$citylink_view = "view=$targetview&postevent=" . $_GET['postevent'];

可以写成:

$foo = $_GET['postevent'];
$citylink_view = "view=$targetview&postevent=" $foo;

你写了:

$posteventview = $_GET['postevent'];
$citylink_view = "view=$targetview&".$posteventview;

您看得出来差别吗?

此外,您可能容易受到 XSS 的攻击。清理输入和urlencode. 使用filter_*函数,例如:

$posteventview = filter_input(INPUT_GET, "postevent");
$citylink_view = "view=$targetview&postevent=" . urlencode($posteventview);
于 2013-03-14T09:21:34.253 回答