Echo "<p>It took {$flipCount} flips!</p>";


My question is we will use concatenation with (.) but echo "

It took {$flipCount} flips!

"; there is to print the variable.May I know what is the meaning of the brackets in this.Thankyou.

echo "<p>It took {$flipCount} flips!</p>";


This is a form of value interpolation which in PHP is called 'complex syntax' since it is able to take complex expressions and convert them to a string. In the case above, we wouldn't normally use the curly braces since we are printing a simple variable. The braces may be removed.(but need not be).

When printing instance variables, such as $this->name it ensures that the the expression is parsed correctly.

echo "The quick brown {$this->animal} jumps over the lazy dog."


Thank you so much :slight_smile: