L
L
Let_peace2021-05-06 22:51:54
PHP
Let_peace, 2021-05-06 22:51:54

"0" == "00" in php. What's the catch?

if("0" == "00") echo('equal');
else echo('not equal');

As a result, the output is 'equal'. I don't see why this is happening. Help me understand this please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Derepko, 2021-05-06
@Let_peace

Implicit comparison, i.e. only content is compared (0 and 00 are converted to int)
https://www.php.net/manual/ru/types.comparisons.php
https://www.php.net/manual/ru/language.operators.c. ..

If both operands are strings containing numbers, or one operand is a number and the other is a string containing numbers, then the comparison is performed numerically

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question