So I am triing to read some php code… I found such line
$uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
what does it mean? and if it (seems for me) just returns ‘file name’ why it is so complicated?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The purpose of that line is to remove values like
openid.something=valuefrom the request URI.There are tools out there to translate regex into prose, with an aim to help you understand what a regex is trying to match. For example, when yours is passed to such a tool the description comes back as:
As the above says, the regex looks for a
?or&followed byopenid., followed by anything not&. The resulting match will include the preceeding&if there is one, but not the?since a look behind was used for the latter.