php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73104 next causes fatal error on constant array
Submitted: 2016-09-18 08:03 UTC Modified: 2016-09-18 16:14 UTC
From: jerry at jmweb dot net Assigned: cmb (profile)
Status: Not a bug Package: Arrays related
PHP Version: 5.6.26 OS: Windows 7 Pro 64bit
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jerry at jmweb dot net
New email:
PHP Version: OS:

 

 [2016-09-18 08:03 UTC] jerry at jmweb dot net
Description:
------------
When creating an array constant, the next() function generates a fatal error.

The key() and current() functions work as expected.

Test script:
---------------
const ARRAY_BUG = [ 1, 2 ];

var_dump(
  key(     ARRAY_BUG ),
  current( ARRAY_BUG ),
  next(    ARRAY_BUG )
);

Expected result:
----------------
int(0)
int(1)
int(2)

Actual result:
--------------
Fatal error: Only variables can be passed by reference in ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-18 16:14 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-09-18 16:14 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

next() is supposed to change the array internally, but constant
array can't be changed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 16:01:38 2025 UTC