php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73802 Operator Precedence
Submitted: 2016-12-21 18:59 UTC Modified: 2016-12-22 01:07 UTC
From: alexwerser at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 7.0.14 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 + 28 = ?
Subscribe to this entry?

 
 [2016-12-21 18:59 UTC] alexwerser at gmail dot com
Description:
------------
On page http://php.net/manual/en/language.operators.precedence.php indicates that the operator ** is of higher priority than ++ -- ~ (int) (float) (string) (array) (object ) (bool) @, but it is not.

Test script:
---------------
// this script returns 9 instead of 15
$a=4;
echo --$a**2;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-22 01:07 UTC] bwoebi@php.net
-Status: Open +Status: Not a bug
 [2016-12-22 01:07 UTC] bwoebi@php.net
The issue is that --($a ** 2) is not a valid expression. Thus the parser parses it the only possible way: (--$a) ** 2.

And the manual is therefore still correct.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC