To compare the type of two variables in PHP, you can use the gettype()
function to determine the type of each variable, and then compare those types using the ===
operator.
For example:
main.php194 chars9 lines
In this example, the gettype()
function is used to determine the type of each variable (integer
and string
, respectively), and then the ===
operator is used to compare the two types. Since the types are different, the else
block is executed and the message "The types of $var1 and $var2 are different." is printed.
gistlibby LogSnag