Php 获取url的特定参数

Php 获取url的特定参数,php,Php,url是http://www.test.co.uk/?set_cp_city=thecity,通常我可以使用$\u GET['set\u cp\u city'],但这不起作用。也许和wordpress有关。那么如何获取参数set\u cp\u city 这是我的密码 <select onChange="window.location.href=this.value"> <?php $locations = array("London","Bristol","Manchest

url是
http://www.test.co.uk/?set_cp_city=thecity
,通常我可以使用
$\u GET['set\u cp\u city']
,但这不起作用。也许和wordpress有关。那么如何获取参数
set\u cp\u city

这是我的密码

  <select onChange="window.location.href=this.value">
<?php
$locations = array("London","Bristol","Manchester","Kent","Essex","Lancashire","Bedfordshire","Berkshire","Buckinghamshire","Cambridgeshire","Cheshire","Cornwall","County Durham","Cumbria","Derbyshire","Devon","Dorset","East Yorkshire","East Sussex","Gloucestershire","Hampshire","Herefordshire","Hertfordshire","Isle of Wight","Leicestershire","Lincolnshire","Merseyside","Norfolk","North Yorkshire","Northamptonshire","Northumberland","Nottinghamshire","Oxfordshire","Rutland","Shropshire","Somerset","South Yorkshire","Staffordshire","Suffolk","Surrey","Tyne and Wear","Warwickshire","West Midlands","West Sussex","West Yorkshire","Wiltshire","Worcestershire");
$current_city = $_GET['set_cp_city'];


echo "<option>$current_city</option>";

foreach($locations as $value) {
?>
<option value="http://www.test.co.uk/?set_cp_city=<?php echo $value ?>"><?php echo $value ?></option>
<?php
}

?>
</select>


$\u服务器['QUERY\u STRING']
应该包含请求的查询,您可以使用
parse\u str()

parse_str($_SERVER['QUERY_STRING'],$output);
print_r($output);
在你的代码中试试这个

$current_city = isset($_GET['set_cp_city'])?$_GET['set_cp_city']:"";

检查您的
.htaccess
并查看其中是否存在
[QSA]
。如果没有,您可能需要在其中一行
ReWrite*
之后添加它。什么是$output?;我尝试了这个方法,结果是
1
尝试回显$\u服务器['QUERY\u STRING'],看看它是否包含您的参数。我想您需要设置值
$data=parse\u url('url')
。该语法用于
parse\u str('query\u string',$return\u Value)
。但无论如何,我不知道这是否仍然有效,奇怪的是,
$\u GET
不起作用