Bug #76959 [Nab]: string concat with or without parenthesis

From: Date: Tue, 02 Oct 2018 15:14:28 +0000
Subject: Bug #76959 [Nab]: string concat with or without parenthesis
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217359@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76959&edit=1 ID: 76959 User updated by: anatole dot ng at free dot fr Reported by: anatole dot ng at free dot fr Summary: string concat with or without parenthesis Status: Not a bug Type: Bug Package: *General Issues Operating System: Linux Mint 18.3 PHP Version: 7.0.32 Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for answering so fast! And sooooory for this "not a bug" request :-( Previous Comments: ------------------------------------------------------------------------ [2018-10-02 14:07:48] cmb@php.net 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" ------------------------------------------------------------------------ [2018-10-02 12:25:13] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76959&edit=1

« previous php.bugs (#217359) next »