從php中刪除一些詞語?從php中刪除一些詞語?
首次訪問頁面例如
www.mysite.com/test.php?ABD_07,_oU_876.00/8999&message=success
從我的PHP代碼,我會得到$curreny_link_redirect
= test.php?ABD_07,_oU_876.00/8999&message=success
,我希望得到$curreny_link_redirect_new
= test.php?ABD_07,_oU_876.00/8999
(切&message=success
)
我該怎麼辦?
<?PHP
$current_link = "$_SERVER[REQUEST_URI]";
$curreny_link_redirect = substr($current_link,1);
$curreny_link_redirect_new = str_replace('', '&message=success', $curreny_link_redirect);
echo $curreny_link_redirect_new;
?>
您確定使用$ current_link =「$ _SERVER [REQUEST_URI]」; ? 它必須是$ current_link = $ _SERVER [「REQUEST_URI」]; – zerokavn
@zerokavn那實際上應該是正確的。 –
爲什麼你不用''_GET'數組而不是'REQUEST_URI'? – Barmar