The Little Guy Posted December 31, 2007 Share Posted December 31, 2007 How can I check to see if a string has special characters in it, or characters that are not allowed in a URL? including the dot/period, slashes (forward, and backwards), question marks, commas, equal, anything and everything, I want letters and number only! Quote Link to comment https://forums.phpfreaks.com/topic/83815-special-characters/ Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 you could use this regexp ((ftp|(http(s)?))://)?(\.?([a-z0-9-]+))+\.[a-z]{2,6}(:[0-9]{1,5})?(/[a-zA-Z0-9.,;\?|\'+&%\$#=~_-]+)*$ Quote Link to comment https://forums.phpfreaks.com/topic/83815-special-characters/#findComment-426485 Share on other sites More sharing options...
marcus Posted December 31, 2007 Share Posted December 31, 2007 Lol. php.net/ctype_alnum Alphanumeric characters. <?php $good = "ily"; $bad = "ihy!"; if(ctype_alnum($good)) echo "You win!\n"; else echo "You fail!\n"; echo "<br>\n"; if(!ctype_alnum($bad)) echo "You fail!\n"; else echo "You win!\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83815-special-characters/#findComment-426486 Share on other sites More sharing options...
thiggins09 Posted December 31, 2007 Share Posted December 31, 2007 These functions will help you along with explanations http://articles.techrepublic.com.com/5100-3513-5899580.html Quote Link to comment https://forums.phpfreaks.com/topic/83815-special-characters/#findComment-426518 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.