|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-10-02 12:25 UTC] anatole dot ng at free dot fr
Description: ------------ Hi guys, Concatenation with some numeric operation results in strange behavior when no parenthesis are used. $str = "Something: " . (5-2) . " foo\n"; $str2 = "Something : " . 5-2 . " foo\n"; Sorry if it's not a bug, and if I'm wrong... Test script: --------------- <?php $str = "Something: " . (5-2) . " foo\n"; $str2 = "Something : " . 5-2 . " foo\n"; echo $str; echo $str2; return Expected result: ---------------- Something: 3 foo Something: 3 foo Actual result: -------------- Something: 3 foo -2 foo PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 20:00:01 2025 UTC |
This is expected behavior. The . and the - operator have the same precedence, and both are left associative, so "Something : " . 5-2 . " foo\n" is evaluated as (("Something : " . 5) - 2) . " foo\n"