If URL contains X do Y

I’m facing a problem with a simple script I wrote. It has to write out an error if there’s a “<” character in the url.

[code]$url = basename($_SERVER[‘PHP_SELF’]).$_SERVER[‘QUERY_STRING’];

if(strpos($url, “<”) !== FALSE) //found
echo die (“error”);[/code]

Which does the right thing for example:

example.com/< will output an error
while
example.com/?< doesn’t output the error.

Does anyone have any idea how do make “<” display the error even if the ? (question mark) is in front of it.

Try this:

[php]strpos($url, “3C”)[/php]

Hope it helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service