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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Fri May 10 19:01:34 2024 UTC