$citylink_view = "view=$targetview&postevent=$_GET[postevent]";
显示未定义的索引:postevent。 我用
解决了这个问题$posteventview = $_GET['postevent'];
$citylink_view = "view=$targetview&".$posteventview;
但这会在我的网址中造成问题。功能不起作用......
答案 0 :(得分: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);