PHP’s type phantom makes string comparison more troublesome, what is the out put of the following code snippet?


$str = '456xyz';
if($str == 456){

echo 'got ya';

}else{

echo 'you got me';

}
Train Asked on February 2, 2016 in PHP.
Add Comment
  • 1 Answer(s)

    Answer is ‘got ya’
    This is because it will convert the string to integer for comparison and the string part will automatically be deleted

    Default Answered on February 2, 2016.
    Add Comment

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.