HGeneAnthony Posted August 19, 2008 Share Posted August 19, 2008 I know how to check to see if a variable is an instanceof a class that I define, however I don't know how to check if it's a string, int, double, etc. Let's say this was my code how could I modify it to check if the data is a string: $name = "gene"; if ($name instanceof string): echo "This is a string"; else: echo "This isn't a string"; endif; Link to comment https://forums.phpfreaks.com/topic/120434-how-to-i-use-instanceof-for-native-data-types/ Share on other sites More sharing options...
corbin Posted August 19, 2008 Share Posted August 19, 2008 http://php.net/is_string http://php.net/is_int http://php.net/is_float http://php.net/is_double But those check the actual data type, not the value, so you might want to look into: http://us.php.net/manual/en/ref.ctype.php Link to comment https://forums.phpfreaks.com/topic/120434-how-to-i-use-instanceof-for-native-data-types/#findComment-620588 Share on other sites More sharing options...
HGeneAnthony Posted August 20, 2008 Author Share Posted August 20, 2008 Thank you I wish I knew about these before they're perfect for the job. Appreciate it! Link to comment https://forums.phpfreaks.com/topic/120434-how-to-i-use-instanceof-for-native-data-types/#findComment-621212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.