Jump to content

How can i check if a string is URL encoded


newb

Recommended Posts

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. }

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.