php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78336 Error compare zero with array[n]
Submitted: 2019-07-26 16:10 UTC Modified: 2019-07-26 16:13 UTC
From: lucastiagodemoraes at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.2.20 OS: Ubuntu 18.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lucastiagodemoraes at gmail dot com
New email:
PHP Version: OS:

 

 [2019-07-26 16:10 UTC] lucastiagodemoraes at gmail dot com
Description:
------------
Hi guys,
See example of bug you will understand. 
If this is normal in PHP is very strange. Thanks.

Test script:
---------------
<?php
$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');

print 0 == $letters[0] ? $letters[0] : 'false';
print 0 == $letters[1] ? $letters[1] : 'false';
print 0 == $letters[2] ? $letters[2] : 'false';
print 0 == $letters[3] ? $letters[3] : 'false';
print 0 == $letters[4] ? $letters[4] : 'false';

Expected result:
----------------
falsefalsefalsefalsefalse

Actual result:
--------------
abcde

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-26 16:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-07-26 16:13 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

https://www.php.net/manual/en/language.operators.comparison.php
https://www.php.net/manual/en/language.types.type-juggling.php
https://www.php.net/manual/en/types.comparisons.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC