Quite often you may need the ability to check what type of data type a variable is.
In most programming languages this is possible to do and is usually called typeof().
PHP too has a way to check this, it is called gettype() and it’s so simple to use.
All you have to do is echo out a call to gettype() with your variable as the first argument.
In the above script we create a function called foo which has 1 argument, it can take any data type so we call it twice, one with a string argument and secondly with an array argument.
Read the official documentation on gettype here.