php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72123 Variable variable assignment from array breaks
Submitted: 2016-04-28 15:38 UTC Modified: 2016-04-28 16:53 UTC
From: haveacigaro at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 7.0.5 OS: osx
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: haveacigaro at gmail dot com
New email:
PHP Version: OS:

 

 [2016-04-28 15:38 UTC] haveacigaro at gmail dot com
Description:
------------
When creating a variable variable from an array, php identifies the string as an array in php 7, but not in previous versions.

Test script:
---------------
<?php

$content = [
    'layout' => 'heading'
];

$heading = function () {
    return "Hi";
};

$layout = "heading";

echo $$layout(); // Works
echo $$content['layout'](); // Doesnt work


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-28 16:53 UTC] jhdxr@php.net
-Status: Open +Status: Wont fix
 [2016-04-28 16:53 UTC] jhdxr@php.net
see http://php.net/manual/en/migration70.incompatible.php

Indirect access to variables, properties, and methods will now be evaluated strictly in left-to-right order, as opposed to the previous mix of special cases. The table below shows how the order of evaluation has changed. 

Code that used the old right-to-left evaluation order must be rewritten to explicitly use that evaluation order with curly braces (see the above middle column). This will make the code both forwards compatible with PHP 7.x and backwards compatible with PHP 5.x.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 21:01:33 2024 UTC