Eritrea Posted October 7, 2012 Share Posted October 7, 2012 Suppose there is a url ex: site.com/page.php?id=*ANTHING* How do you check if *ANYTHING* is only string ( not composed of strings and integers ) or integer only. Because, I used is_string() function to check it, but it only checks if the first letter is a string so id=?cat435 and id=?catdasd will return the same result. How can I make sure, if a value is then only a string or integer and not a combination of both thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 7, 2012 Share Posted October 7, 2012 A string CAN contain integers. If you want only a-z, use a regex. Quote Link to comment Share on other sites More sharing options...
Eritrea Posted October 7, 2012 Author Share Posted October 7, 2012 Thank you Jessica, I just realized that. Since, I've seen regex is used to manipulate string data. Somehow, every time I see it, it scares me. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 7, 2012 Share Posted October 7, 2012 is_string() will always return TRUE for form data because all form data is sent as string type. What you need if all you want is letters in the string is ctype_digit. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 7, 2012 Share Posted October 7, 2012 Sorry, make that ctype_alpha, not ctype_digit() (derp). Quote Link to comment 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.