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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 - 28 = ?
Subscribe to this entry?

 
 [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: Fri May 10 08:01:33 2024 UTC