php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sven at democopei dot de
New email:
PHP Version: OS:

 

 [2011-02-06 03:33 UTC] sven at democopei dot de
Description:
------------
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 ();
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-07 10:54 UTC] mj@php.net
-Status: Open +Status: Feedback
 [2011-02-07 10:54 UTC] mj@php.net
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?

<?php
function &foo_to_array (&$x)
{
  $array_to_return = array();                                                 
  return $array_to_return;
}

$x = "";
var_dump(foo_to_array($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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC