/ Published in: PHP
A better and more accurate function to see if a value is an integer.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
return ((int)$int == $int) ? true: false; } return FALSE; } /* // test code print("155 - ".int(155)."<br>"); print("15.5 - ".int(15.5)."<br>"); print("\"155\" - ".int("155")."<br>"); print("\"15.5\" - ".int("15.5")."<br>"); print("\"0155\" - ".int("0155")."<br>"); print("\"I'm 155\" - ".int("I'm 155")."<br>"); print("\"test\" -- ".int(true)."<br>"); print("\"\" - ".int("")); */