|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53936 Literal empty array returns NULL.
Submitted: 2011-02-06 03:33 UTC Modified: 2011-02-28 10:17 UTC
From: sven at democopei dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.5 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: sven at democopei dot de
New email:
PHP Version: OS:


 [2011-02-06 03:33 UTC] sven at democopei dot de
For some reason I cannot figure out, array() doesn't give me an empty array anymore but NULL.

(References are used for good reasons, btw.)

Test script:
function &foo_to_array (&$x)
    $array_to_return = array (); // Works the first couple of times, then NULLs.
    // add foo elements to array
    return $array_to_return;

Introducing some wrapper doesn't help either -- an array is actually created but NULL is returned anyway:

function make_array ()
    return array ();


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-07 10:54 UTC]
-Status: Open +Status: Feedback
 [2011-02-07 10:54 UTC]
I cannot reproduce this with the code below.  Are you running some extension like APC or Zend Guard that mangles/optimizes the code for you?

function &foo_to_array (&$x)
  $array_to_return = array();                                                 
  return $array_to_return;

$x = "";
 [2011-02-07 17:49 UTC] sven at democopei dot de
-Status: Feedback +Status: Open
 [2011-02-07 17:49 UTC] sven at democopei dot de
No, I'm sorry. I don't use any extensions or Zend. As I said, I cannot boil this down to its essence - I have some very large, generated PHP script I'm willing to send you via PM, though.
 [2011-02-28 10:17 UTC] sven at democopei dot de
-Status: Open +Status: Closed
 [2011-02-28 10:17 UTC] sven at democopei dot de
Couldn't find anything to help finding the buggy spot. Rewrote my thing without pass-by-reference and it now works nicely. Sorry.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 20:03:37 2021 UTC