note 119689 deleted from function.echo by cmb
| From: | cmb@php.net | Date: | Tue, 20 Nov 2018 18:12:34 +0000 |
| Subject: | note 119689 deleted from function.echo by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209739@lists.php.net to get a copy of this message | ||
Note Submitter: Jamie Robinson
----
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.