obay Posted August 3, 2007 Share Posted August 3, 2007 How do I determine the data type of any variable? any function available? I'm having trouble because i do a print_r($var); and it outputs Array ( .... ) but when i do an array_key_exists("something",$var) it returns says second argument must be array or object im confused. even is_array($var) returns true Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/ Share on other sites More sharing options...
btherl Posted August 3, 2007 Share Posted August 3, 2007 The function is http://sg.php.net/manual/en/function.gettype.php I'm interested to see what it returns for your mystery variable.. Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314590 Share on other sites More sharing options...
obay Posted August 3, 2007 Author Share Posted August 3, 2007 btherl, i modified my message above Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314592 Share on other sites More sharing options...
obay Posted August 3, 2007 Author Share Posted August 3, 2007 okay i used gettype($var) it returned "array". but array_key_exists() still doesn't recognize $var as an array what's wrong? Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314594 Share on other sites More sharing options...
dbillings Posted August 3, 2007 Share Posted August 3, 2007 show us all the code not just chunks Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314596 Share on other sites More sharing options...
btherl Posted August 3, 2007 Share Posted August 3, 2007 Can you post a short script reproducing the problem? If that's not possible, please post your entire script. Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314597 Share on other sites More sharing options...
obay Posted August 3, 2007 Author Share Posted August 3, 2007 really weird.. the code works now... i.e. array_key_exists()... im confused why... ??? ??? ??? but anyway, it works now... sorry for wasting your time guys.. Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314609 Share on other sites More sharing options...
btherl Posted August 3, 2007 Share Posted August 3, 2007 The most likely reason is that you accidentally changed the value of $var and didn't realize it. Then you didn't realize when you fixed the code that changed it either The other most likely reason is a typo in a variable name, but that's unlikely for such a short name. Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314615 Share on other sites More sharing options...
obay Posted August 3, 2007 Author Share Posted August 3, 2007 Yes, i must have done something to the code i didn't notice. Thanks though!!! =) Link to comment https://forums.phpfreaks.com/topic/63130-solved-how-do-i-determine-the-data-type-of-any-variable/#findComment-314685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.