note 12149 modified in language.operators by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 19:04:50 +0000 |
| Subject: | note 12149 modified in language.operators by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142548@lists.php.net to get a copy of this message | ||
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".
?>
--was--
About "{" and "}".
Sometimes PHP programmers need to use "{" and "}" to resolve ambiguity. Here is
some examples.
Variable Variables:
$foo = "test";
$$bar = "this is";
echo "${$bar} $foo"; // prints "this is test"
Note: it is the same as
echo "$test $foo";
Array in string:
$arr[10][10][10] = "string";
echo "This is {$arr[10][10][10]}"; // prints "This is string"
Associative Array in string:
$arr['item'] = 'string';
echo "This is {$arr['item']}"; //prints "This is string".
http://php.net/manual/en/language.operators.php