Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialgiseletoledo2
3,480 PointsHow can i create a function to compare data type? Should I use var_dump?
I just want to pratice the PHP basics , if I want to create a function that compare if a data is integer before make a sum, how should I create the code?
2 Answers
Corey Cramer
9,453 PointsPHP has a specific function for various data types. In this case it is
is_int($var)
There are however other functions to check if the variable is an array, boolean, double, float, null, object, string, etc.
giseletoledo2
3,480 PointsThank you, so I don't need to create a function, PHP already has a function.
Corey Cramer
9,453 PointsAs you continue your journey you'll probably find that that's often the case. There are all sorts of hidden functions that I was re-writing myself because I didn't know they existed. Part of my continued learning is teaching myself how to be a better researcher to discover those things before creating them.