我通过查询字符串获得一个值,但在打印值时遇到了一些问题
查询字符串为
http://mastertrade.in/master/wpfiles/corp_announcements.php?tpnt=5544&caption=%22KNRCON%20-%20Press%20Release%22
然后我得到了像这个这样的GET方法的标题
$cap=$_GET[能力];
打印此变量$cap时我收到这个了
'"KNRCON - Press Release'"
我不想要
''
打印时我该怎么办?我试过
preg_replace('/'/','',$cap);
但我得到
preg_replace() [function.preg-replace]: No ending matching delimiter '/'
有一个函数可以删除escape斜杠stripshases
$cap = stripslashes($cap);
答案不错。但没有人建议关闭Magic Quotes。或者使用get_magic_quotes_gpc
/。http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
$caption = $_GET['caption'];
if (get_magic_quotes_gpc()) {
$caption = stripslashes($caption);
}
<?php
$string = ''"KNRCON - Press Release'"';
echo str_replace(array(''/',''''),'',$string); //Output: "KNRCON - Press Release"
?>