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 Link to comment https://forums.phpfreaks.com/topic/269194-how-to-check-a-_get-value-is-100-string-or-integer/ 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. Link to comment https://forums.phpfreaks.com/topic/269194-how-to-check-a-_get-value-is-100-string-or-integer/#findComment-1383498 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. Link to comment https://forums.phpfreaks.com/topic/269194-how-to-check-a-_get-value-is-100-string-or-integer/#findComment-1383500 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. Link to comment https://forums.phpfreaks.com/topic/269194-how-to-check-a-_get-value-is-100-string-or-integer/#findComment-1383512 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). Link to comment https://forums.phpfreaks.com/topic/269194-how-to-check-a-_get-value-is-100-string-or-integer/#findComment-1383517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.