newb Posted November 22, 2011 Share Posted November 22, 2011 How can i check if a string is URL encoded or not using PHP Quote Link to comment https://forums.phpfreaks.com/topic/251585-how-can-i-check-if-a-string-is-url-encoded/ Share on other sites More sharing options...
teynon Posted November 22, 2011 Share Posted November 22, 2011 I haven't done a whole lot of googling here, but you could use this statement from PHP.net for urlencode: Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. This would possibly correlate to a preg match like this: if (preg_match("@^[a-zA-Z0-9%+-_]*$@", $variable)) { // variable is urlencoded. } Quote Link to comment https://forums.phpfreaks.com/topic/251585-how-can-i-check-if-a-string-is-url-encoded/#findComment-1290261 Share on other sites More sharing options...
newb Posted November 22, 2011 Author Share Posted November 22, 2011 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/251585-how-can-i-check-if-a-string-is-url-encoded/#findComment-1290262 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.