0
我試圖逃避一切從URI除了字母,數字,替換 - ,和/,所以我做了下面的正則表達式,並把它變成一個preg_replace
功能。但是,如果我喜歡/dir/anotherDir<?<<<?>
輸入的東西它不會刪除它來將其替換比3C
和3E
我怎麼能解決這個問題比大於和小於?PHP的正則表達式用數字和字符不爲空
$uriPath = htmlentities($uriPath);
$patterns = array('/[^a-zA-Z0-9\.\-\/]/', '/\.+/', '/\.+\//', '/\.+\.+\//');
$uriPath = preg_replace($patterns, '', $uriPath);
究竟是什麼你想怎麼辦? – anubhava
@anubhava我試圖清理鍵入到瀏覽器中使用 – zachstarnes
'preg_quote'轉義一個URI。 – anubhava