note 12149 deleted from language.operators by danbrown
| From: | danbrown@php.net | Date: | Fri, 30 Jan 2009 20:47:19 +0000 |
| Subject: | note 12149 deleted from language.operators by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150012@lists.php.net to get a copy of this message | ||
Note Submitter: yasuo_ohgaki at hotmail dot com
----
About "{" and "}".
Sometimes PHP programmers need to use "{" and "}" to resolve ambiguity. Here is
some examples.
Variable Variables:
<?php
$foo = "test";
$$bar = "this is";
echo "${$bar} $foo"; // prints "this is test"
?>
Note: it is the same as
<?php echo "$test $foo"; ?>
Array in string:
<?php
$arr[10][10][10] = "string";
echo "This is {$arr[10][10][10]}"; // prints "This is string"
?>
Associative Array in string:
<?php
$arr['item'] = 'string';
echo "This is {$arr['item']}"; //prints "This is string".
?>