可以說,網址是http://example.com/product/3
,我只想檢索http://example.com/product/
之後的內容。我發現這一點,它回聲的領域,但我怎麼得到這三個。它的這種方法可靠嗎?我也使用codeIgniter。如何從PHP中的URL中獲取信息?
<?php
function curPageURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
<?php
echo curPageURL();
?>
確定它的工作視圖爲 $ this-> uri-> segment(2); – ThomasReggi 2010-06-24 20:03:07