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

From: Date: Mon, 06 Apr 2020 08:42:21 +0000
Subject: Re: Comparing non-empty string and 0 - is this behavior to be expected?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-327093@lists.php.net to get a copy of this message
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 <https://www.php.net/manual/en/language.types.string.php#language.types.string.conversion> and the comparison performed numerically. Janis svētd., 2020. g. 5. apr., plkst. 09:38 — lietotājs Jeremy O'Connor (< jeremyo@afrihost.co.za>) 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 >

« previous php.general (#327093) next »