Сведения о вопросе

Gentleman

17:32, 22nd August, 2020

Теги

PHP    

Типы в PHP. Разрыв шаблона

Просмотров: 352   Ответов: 1

<?php
$result = (0 == "php") ? TRUE : FALSE;
var_dump($result);

// Почему TRUE???



  Сведения об ответе

lourence

21:16, 23rd August, 2020

Потому, что PHP. Привыкайте к нелогичности. Шаблон еще себе сломаете тотально =)

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.


www.php.net/manual/en/language.types.string.php#language.types.string.conversion
The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero).


Ответить на вопрос

Чтобы ответить на вопрос вам нужно войти в систему или зарегистрироваться