note 114500 added to language.operators.precedence
| From: | Antistone | Date: | Thu, 27 Feb 2014 23:46:33 +0000 |
| Subject: | note 114500 added to language.operators.precedence | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198744@lists.php.net to get a copy of this message | ||
BEWARE: Addition, subtraction, and string concatenation have equal precedence!
<?
$x = 4;
echo "x minus one equals " . $x-1 . ", or so I hope";
?>
will print "-1, or so I hope"
(Concatenate the first string literal and the value of $x, then implicitly convert that to a number
(zero) so you can subtract 1 from it, then concatenate the final string literal.)
----
Server IP: 192.41.45.150
Probable Submitter: 216.23.182.4
----
Manual Page -- http://php.net/manual/en/language.operators.precedence.php
Edit -- https://master.php.net/note/edit/114500
Del: integrated -- https://master.php.net/note/delete/114500/integrated
Del: useless -- https://master.php.net/note/delete/114500/useless
Del: bad code -- https://master.php.net/note/delete/114500/bad+code
Del: spam -- https://master.php.net/note/delete/114500/spam
Del: non-english -- https://master.php.net/note/delete/114500/non-english
Del: in docs -- https://master.php.net/note/delete/114500/in+docs
Del: other reasons-- https://master.php.net/note/delete/114500
Reject -- https://master.php.net/note/reject/114500
Search -- https://master.php.net/manage/user-notes.php