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! 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.,;\?|\'+&%\$#=~_-]+)*$ 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"; ?> 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 Link to comment https://forums.phpfreaks.com/topic/83815-special-characters/#findComment-426518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.