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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC