php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47738 passing empty array to a function with a null-default argument results in null
Submitted: 2009-03-20 22:47 UTC Modified: 2009-03-20 23:04 UTC
From: alexanderpodgorny at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.9 OS: Mac OS X
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: alexanderpodgorny at yahoo dot com
New email:
PHP Version: OS:

 

 [2009-03-20 22:47 UTC] alexanderpodgorny at yahoo dot com
Description:
------------
When passing empty arrays to a function using a parameter that defaults to null, the default value is being passed instead of the array.

Reproduce code:
---------------
function test($value=null) {
 		if($value == null) {
 			print "null";
 		} else {
 			print "not null";
 		}
 	}

	test(array());

Expected result:
----------------
"not null"

Actual result:
--------------
"null"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-20 23:04 UTC] felipe@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

See the 'Loose comparisons with ==' table at http://docs.php.net/manual/en/types.comparisons.php

Thanks.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 14:00:02 2025 UTC