php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70095 Operator precedence changed in PHP 7
Submitted: 2015-07-18 16:14 UTC Modified: 2018-05-05 11:00 UTC
Votes:2
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: me at evertpot dot com Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.0beta1 OS: Any
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: me at evertpot dot com
New email:
PHP Version: OS:

 

 [2015-07-18 16:14 UTC] me at evertpot dot com
Description:
------------
The code from the description now has a different output. I'm not sure if it's intentional, so I decided to post it as a bug. It's definitely a BC change.

Also see:

http://3v4l.org/pE0UN



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

$foo = [
   'a' => 'b'    
];

$bar = [
   'b' => 'c'  
];

$bar = (object)$bar;

// Note that the following line is interpreted as
// $bar->b in PHP < 7, and $bar->Array in PHP > 7.
echo $bar->$foo['a'];

Expected result:
----------------
c


Actual result:
--------------
Notice: Array to string conversion in /in/pE0UN on line 14 Notice: Undefined property: stdClass::$Array in /in/pE0UN on line 14

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-18 16:19 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-07-18 16:19 UTC] requinix@php.net
Yes, it's intentional. https://wiki.php.net/rfc/uniform_variable_syntax
 [2015-07-18 16:37 UTC] pasindu@php.net
-Status: Not a bug +Status: Assigned -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: pasindu
 [2015-07-18 16:37 UTC] pasindu@php.net
This is probably not documented, TODO for documentation
 [2017-10-24 06:28 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: pasindu +Assigned To:
 [2018-05-05 11:00 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-05-05 11:00 UTC] cmb@php.net
Since this issue is now documented in the migration guide[1], and
also has a cautionary note in the variable variables section[2],
this ticket can be closed.

[1] <http://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.indirect>
[2] <http://www.php.net/manual/en/language.variables.variable.php>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC