|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74732 Boolean and int values are not implicitly cast during comparison
Submitted: 2017-06-09 18:56 UTC Modified: 2018-08-27 10:04 UTC
From: smorozov at sugarcrm dot com Assigned: vnkbabu (profile)
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 7.1.6 OS: Ubuntu 16.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: smorozov at sugarcrm dot com
New email:
PHP Version: OS:


 [2017-06-09 18:56 UTC] smorozov at sugarcrm dot com
In PHP 5.6, if a boolean value is compared with an int, it's cast to int, so true == 1 and false == 0. In PHP 7.0 and 7.1, the comparison true == 1 returns false.

The script below works as expected on PHP 5.6 but doesn't on PHP 7.

Unlike, this behavior doesn't depend on whether Opcache is enabled or not.

Test script:
$dsn = 'HOSTNAME=localhost;UID=db2inst1;PWD=Passw0rd;DATABASE=test';
$conn = db2_connect($dsn, null, null);

if (!$conn) {
    echo db2_conn_errormsg(), PHP_EOL;

$stmt = db2_prepare($conn, 'SELECT 1 FROM SYSIBM.SYSDUMMY1 WHERE 1 = ?');

db2_execute($stmt, [true]);

db2_execute($stmt, [1]);

Expected result:
array(1) {
array(1) {

Actual result:
array(1) {


boolean_path (last revision 2017-07-17 08:39 UTC by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-13 11:15 UTC]
-Status: Open +Status: Assigned
 [2017-07-13 11:15 UTC]
Our developer Abhinav Radke from IBM is working on this defect. HE is able to reproduce the issue, he is reaching out to the zend guys to fix the issue. Will update once he has the solution for this issue.
 [2017-07-17 08:39 UTC]
The following patch has been added/updated:

Patch Name: boolean_path
Revision:   1500280746
 [2017-07-17 08:40 UTC]
  Our developer has fixed the issue. Please use the below patch to fix the problem.
 [2017-07-19 09:15 UTC] smorozov at sugarcrm dot com
Thank you! It works with the patch.
 [2018-08-27 10:04 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: vnkbabu
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 26 12:03:35 2021 UTC