P
P
pdx2011-02-12 14:21:14
PHP
pdx, 2011-02-12 14:21:14

Types in PHP. Template break

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

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
VBart, 2011-02-12
@pdx

Because PHP. Get used to the inconsistency. You will break the template completely =)
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).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question