php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17569 array_push creates array if var is not set
Submitted: 2002-06-02 19:47 UTC Modified: 2002-06-02 19:48 UTC
From: tim at timcrider dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.2.1 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: tim at timcrider dot com
New email:
PHP Version: OS:

 

 [2002-06-02 19:47 UTC] tim at timcrider dot com
Right now if you call array_push and the array parameter is not set, it gives the error

Warning: First argument to array_push() needs to be an array in FILE on line NUM

array_push should check to see if the variable is set or NULL. Only if it is NULL should it create a new array. If there is already something assigned to the var it should do nothing.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-02 19:48 UTC] mfischer@php.net
No, it should not. It's up to the user to pass an array to the function. Use is_array() to check if it's actually an array you pass or not.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 18:01:35 2024 UTC