问题
I am searching for a way to find a url that contains a parameter to extract a dynamic value
example, anywhere on my website there is a button with a link that contains characters
example.com/register/register-company.html?tx_powermail_pi1[regUid]=78
i need the id from regUid to work with queries, the 78 is not static.
thx for any help.
回答1:
$str = "http://example.com/somepage?tx_powermail_pi1[regUid]=78";
$uri = parse_url($str);
if($uri["query"]){
#if there is query string only....
parse_str($uri["query"], $test);
var_dump($test);
}
This will work on any url. If you are trying to catch your current url get param you can just use
$_GET['tx_powermail_pi1']['regUid']
来源:https://stackoverflow.com/questions/15875547/find-parameters-in-url-using-php