note 119689 added to function.echo
| From: | JamieRobinson | Date: | Wed, 03 Aug 2016 16:57:16 +0000 |
| Subject: | note 119689 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206200@lists.php.net to get a copy of this message | ||
The {} syntax is useful for printing non array variables as well, an example to illustrate:
<?php
$foo = "foobar";
$bar = "barbaz";
//Will produce the error: Undefined variable: $foo_
echo "$foo_$bar";
//Will print the intended string: "foobar_barbaz"
echo "{$foo}_$bar";
?>
Could even be worth getting into the habit of enclosing all variables in {} when writing echo
strings, to be on the safe side.
----
Server IP: 72.52.91.14
Probable Submitter: 81.2.65.214
----
Manual Page -- http://php.net/manual/en/function.echo.php
Edit -- https://master.php.net/note/edit/119689
Del: integrated -- https://master.php.net/note/delete/119689/integrated
Del: useless -- https://master.php.net/note/delete/119689/useless
Del: bad code -- https://master.php.net/note/delete/119689/bad+code
Del: spam -- https://master.php.net/note/delete/119689/spam
Del: non-english -- https://master.php.net/note/delete/119689/non-english
Del: in docs -- https://master.php.net/note/delete/119689/in+docs
Del: other reasons-- https://master.php.net/note/delete/119689
Reject -- https://master.php.net/note/reject/119689
Search -- https://master.php.net/manage/user-notes.php