You can use parse_url
and parse_str
like this:
$query = parse_url('http://www.example.com?test=123&random=abc', PHP_URL_QUERY);
parse_str($query, $params);
$test = $params['test'];
parse_url
allows to split an URL in different parts (scheme, host, path, query, etc); here we use it to get only the query (test=123&random=abc
). Then we can parse the query with parse_str
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…