php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22611 ? : operator precedence is wrong
Submitted: 2003-03-08 13:46 UTC Modified: 2003-03-09 18:29 UTC
From: pts+phpbug at math dot bme dot hu Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
 [2003-03-08 13:46 UTC] pts+phpbug at math dot bme dot hu
<?php echo 1 ? 2 : 3 ? 4 : 5;            
# ^^^ should echo `2', but echoes `4' in PHP 4.3.1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-09 18:29 UTC] moriyoshi@php.net
This looks really weird, but it's by design. In PHP "?" have left associativity in contrast to other languages such as perl in which they have right associativity.

See also
http://www.php.net/manual/en/language.operators.php
http://www.perldoc.com/perl5.8.0/pod/perlop.html
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 05:01:31 2024 UTC