PHP Behavior on Strings and numbers

The variable in the PHP is declared as $variable_name e.g. '$val' . Thus we can store both 'Strings' and 'Numbers' in the variables of PHP. 

What PHP does is if you compare a 'String' and' Number' , PHP implicitly casts the String into corresponding Numeric and compares it. This means if we will compare "10" and 10 the result will be true as shown by the below example when you run the code. 

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy