[php-src] Issue #11664: Comparators and returning negative value from Function

From: Date: Mon, 10 Jul 2023 15:46:25 +0000
Subject: [php-src] Issue #11664: Comparators and returning negative value from Function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244936@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11664 Author: RWAP ### Description The following code: ```php public function saveSubUserToDB(MyPDO $DB) { $encryption = $this->saveEncryptedToDB($DB); if ($encryption == -100) { echo 'Error'; )); return true; } } public function saveEncryptedToDB(MyPDO $DB) { try { $params = array(':id'=>$this->id, ':email'=>$this->email ); if (!count($DB->query('select id from '.self::DB_SECURE_TABLE.' where id="'.$this->id.'" limit 1')->fetchAll())) { //it doesn't exist yet $sql = 'insert into '.self::DB_SECURE_TABLE.' (id, email) values (:id,:email)'; $query = $DB->prepare($sql); $result = $query->execute($params); unset($query); return $result; } else { $sql = 'update '.self::DB_SECURE_TABLE.' set email=:email where id=:id limit 1'; $query = $DB->prepare($sql); $result = $query->execute($params); unset($query); return result; } } catch(Exception $e) { return -100; } } <?php ``` Resulted in this output: Error But I expected this output instead: Assuming the SQL call is valid, the returned value of $encrypted is a boolean true, but the comparator if ($encrypted == -100) { } is seen as true for some reason. This is in PHP 7.4..33 ### PHP Version PHP 7.4.33 ### Operating System _No response_

« previous php.bugs (#244936) next »