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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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 23:01:30 2024 UTC