note 124137 added to language.operators.string
| From: | ivan at trive dot digital | Date: | Sun, 25 Aug 2019 13:46:27 +0000 |
| Subject: | note 124137 added to language.operators.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212013@lists.php.net to get a copy of this message | ||
also similar example of caution for precedence, which may or may not be obvious from first note
<?php
$array = [
'message' => 1
];
echo 'Message is '
. isset($array['msg'])
? $array['msg']
: $array['message'];
?>
will throw an _Undefined index exception_ as
isset() has the same precedence as
concatenate.
place it in a variable before concatenating as a method to avoid this.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.168 (proxied: 93.140.68.142)
----
Manual Page -- http://php.net/manual/en/language.operators.string.php
Edit -- https://master.php.net/note/edit/124137
Del: integrated -- https://master.php.net/note/delete/124137/integrated
Del: useless -- https://master.php.net/note/delete/124137/useless
Del: bad code -- https://master.php.net/note/delete/124137/bad+code
Del: spam -- https://master.php.net/note/delete/124137/spam
Del: non-english -- https://master.php.net/note/delete/124137/non-english
Del: in docs -- https://master.php.net/note/delete/124137/in+docs
Del: other reasons-- https://master.php.net/note/delete/124137
Reject -- https://master.php.net/note/reject/124137
Search -- https://master.php.net/manage/user-notes.php