I would like to get parameter from variable that holds URL.
I got the following variable: $lastPage
that holds the URI of the previous page.
I would like to get a parameter from it.
I got the following script in javascript (which I use for something else)
function getUrlVar(key)
{
var result = new RegExp(key + '=([^&]*)', 'i').exec(window.location.search);
return result && unescape(result[1]) || '';
}
I want something like that but for PHP.
Thank you very much
You can use preg_match()
or preg_match_all()
in php which will give you the regular expression functionality.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.