Bug #79894 [Com]: ternary condition perturbates if condition

From: Date: Thu, 17 Dec 2020 15:46:15 +0000
Subject: Bug #79894 [Com]: ternary condition perturbates if condition
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231135@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79894&edit=1 ID: 79894 Comment by: andrew dot engdahl at gmail dot com Reported by: fabien dot aurejac at gmail dot com Summary: ternary condition perturbates if condition Status: Closed Type: Bug Package: *General Issues Operating System: debian 10.4 PHP Version: 7.2.32 Block user comment: N Private report: N New Comment: The example given returns the correct result. The ternary operator is would always return a string which is always truthy. Even the integers 1 or 2 would evaluate as true; however, 0 would be false. Only the following would provide the result of 0: if (false && true ? 1 : 0) { echo 1; } else { echo 0; } Previous Comments: ------------------------------------------------------------------------ [2020-07-24 17:47:25] fabien dot aurejac at gmail dot com seems to be an error on my side... I omit the priority of operators ------------------------------------------------------------------------ [2020-07-24 17:44:24] fabien dot aurejac at gmail dot com Ok, seems ------------------------------------------------------------------------ [2020-07-24 17:42:22] fabien dot aurejac at gmail dot com Description: ------------ When I try this script it should at my point of view return 0 instead of 1 ? am I mistaken ? Test script: --------------- <?php if (false && true?"1":"2") { echo 1; } else { echo 0; } ?> Expected result: ---------------- 0 Actual result: -------------- 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79894&edit=1

« previous php.bugs (#231135) next »