What is the usage of {} in strings?
For instance, where there is ambiguity as to how to interpret a string, we can use the {} to tell PHP exactly what we mean as follows.
Or if we want to print a variable and immediately follow it with more text, then we can use the {} to allow this.
Take a look at the difference between these two:
<?php
$mystring = "stand";
echo "$mystringup and be counted!";
//PHP Notice: Undefined variable: mystringup in C:\phptest\sample.php on line 5 and be counted!
echo "{$mystring}up and be counted!";
//prints: standup and be counted!
?>
Comment on this Question and Answer >>>
ASK A QUESTION
More strings PHP Questions
How do I replace a word in a string in PHP?print(1 . " + " . 2 . " = " . 1+2 . "n"); gives answer 3 why?
How do I convert characters to HTML entities using PHP?
How do I find the length of a string in PHP?
How do I extract the values of variables from a string?
