mysql - php database - is_int returns false always -


i have written simple sql query , is_int() returns alway false. why?

mysql query

$sql = "select id, username users email = 'mail@example.com' limit 1";  $data = $db->query($sql);  # output: php array $data[0]['id']; 

php if

if( is_int($data[0]['id'] ){   print 1; }else{   print 0; } 

// edit var_dump print this:

array(2) { ["id"]=> string(1) "1" ["username"]=> string(6) "admin" } 

why 'id' string , not integer?

how can "id" not integer?

if want check value:

<?php function is_int_val($val) {     return $val == (string)((int)$val); } echo (is_int_val(33) ? "true" : "false")."\n"; // returns true echo (is_int_val("33") ? "true" : "false")."\n"; // returns true echo (is_int_val("33.0") ? "true" : "false")."\n"; // returns true echo (is_int_val("a33") ? "true" : "false")."\n"; // returns false echo (is_int_val("33a") ? "true" : "false")."\n"; // returns false 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -