Re: Comparing non-empty string and 0 - is this behavior to be expected?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Which statement puzzles you exactly?

Regarding the last one:
From https://www.php.net/manual/en/language.operators.comparison.php
> If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.

Janis

svētd., 2020. g. 5. apr., plkst. 09:38 — lietotājs Jeremy O'Connor (<jeremyo@xxxxxxxxxxxxxx>) rakstīja:
Looking at the following code

echo ('') ? 'T' : 'F';
echo ('!') ? 'T' : 'F';
echo (0) ? 'T' : 'F';
echo ('' == 0) ? 'T' : 'F';
echo ('!' == 0) ? 'T' : 'F';

the output is:

FTFTT

Is this behavior to be expected?

--
Jeremy O'Connor

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux