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
 [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