php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70649 Array_sum when array content are nuls
Submitted: 2015-10-06 11:50 UTC Modified: 2015-10-06 19:56 UTC
From: marc dot lazzaro at st dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.4.45 OS: Windows XP
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: marc dot lazzaro at st dot com
New email:
PHP Version: OS:

 

 [2015-10-06 11:50 UTC] marc dot lazzaro at st dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-sum
---
$arr = array(null,null,null);
$sum = array_sum($arr);

expected value = null
returned value = 0

Test script:
---------------
$arr = array(null,null,null);
$sum = array_sum($arr);
echo $sum;

Expected result:
----------------
NULL

Actual result:
--------------
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-06 19:56 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-10-06 19:56 UTC] requinix@php.net
null+null+null=0
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC