Comparison of string “10″ and integer 11

Will comparison of string “10″ and integer 11 work in PHP?

I’d assume ali0482 means < and > comparison. And yes, you can.

Strange ol’ question, but I’ll humour you. :slight_smile:


<?php

var_dump(
  '10' == 11
); #false

var_dump(
  '10' === 11
); #false

var_dump(
  '10' == '11'
); #false

var_dump(
  '10' === '11'
); #false

?>

Compare how?
Did you try?

var_dump("11">10);
// true

var_dump("10">11);
// false

Fundamental to PHP programming, you need to understand string conversion to numbers and remember that when analysing any variable - especially when forking your code then use var_dump() for evidence of what PHP has understood a variable to be.