Posted by Jochem Maas on 04/06/05 12:53
Jacques wrote:
> I have often seen php code included inside braces. What does this mean or
> do?
you mean inside a double quoted string? like:
<?php
$var = "{$myArray[$myAssocKey]} {$myObj->property}";
?>
the braces are used to delimit the variables that are to be interpolated,
this is done to make sure that PHP doesn't get confused about which part
of the string is a 'var' that needs to be replaced.
searching on php + 'string interpolation' should give you more info on the matter.
.... also braces can be used for direct access to chars in a string e.g:
<?php
$myString = "my String";
echo $myString{3}; // gimme a "S"
?>
....and if you mean braces like the following, then you need to go to the manual and
read up on 'control structures':
<?php
if ($x) {
echo '$x casts to boolean true!';
}
?>
>
> Jacques
>
Navigation:
[Reply to this message]
|