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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Thu Aug 06 02:01:24 2020 UTC