我为我的生活无法弄清这一点......从php url字符串中删除中断?
我有一个表单,它最终将查询字符串传递一些字段。
$f = $_GET['full'];
$t = $_GET['title'];
$illegal = array("'", "#039;");
$f = str_replace($illegal, "", $f);
$t = str_replace($illegal, "", $t);
出于某种奇怪的原因,省略号那里搞乱我需要什么,所以我删除他们,因为他们是(对于第一次出现和#039 ';之后)转动起来。
现在$ t输出一个可用的字符串。 $ f但可以包含休息。而他们最终的字符串作为
<br+%2F>
我已经试过
$f = preg_replace("/\r?\n/", "", $f);
和
$breaks = array("<br+%2F>", "/\r?\n/", "<br />");
$f = str_replace($breaks, "%20", $f);
,但是当我将它输出在URL我仍然得到
http://www.domain.com?t=good%20string&f=bad<br+%2F>string
正在导致404页未找到错误。 :(
编辑
$f = html_entity_decode($_GET['full']);
$t = html_entity_decode($_GET['title']);
$illegal = array("'", "#039;");
$f = str_replace($illegal, "", $f);
$t = str_replace($illegal, "", $t);
$f = htmlspecialchars($f);
$breaks = array("<br+%2F>%0D%0A<br+%2F>%0D%0A", "<br+%2F>%0D%0A");
$f = str_replace($breaks, "%20", $f);
if (---private-stuff---) {
header('Location: /?title=' . $t . '&full=' . $f . '&fifth=fith%20percent');
}
最后$ F仍然包含
<br+%2F>%0D%0A<br+%2F>%0D%0A
在url
,不应该对这些功能ONE剥离出来?!?
404代表URL地址无效。意思是你应该试试'http://www.domain.com/index.php?...' – 2012-07-19 00:34:57
我明白404是什么 - 但是http://www.domain.com?t=good%20string&f=bad
字符串给出了404。如果我删除了
,它工作得很好。 – Xhynk 2012-07-19 00:37:56