共計(jì) 458 個(gè)字符,預(yù)計(jì)需要花費(fèi) 2 分鐘才能閱讀完成。
要獲取 URL 參數(shù),你可以使用 PHP 中的 $_GET
或$_REQUEST
全局變量。例如,如果你的 URL 是 http://example.com/index.php?page=about
,你可以使用以下代碼來獲取page
參數(shù)的值:
$page = $_GET['page'];
echo $page; // 輸出為 "about"
如果你想重寫 URL 并隱藏參數(shù),你可以使用 .htaccess
文件來實(shí)現(xiàn)。例如,你可以將 http://example.com/index.php?page=about
轉(zhuǎn)換為 http://example.com/about
。在.htaccess
文件中添加以下代碼:
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?page=$1 [L]
這將把 http://example.com/about
重寫為http://example.com/index.php?page=about
。然后你可以使用上面的 PHP 代碼來獲取參數(shù)的值。
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!
正文完