Use curly brace in single quote


How to use the following code with single quote please ?

echo "There are three {$my_var}s on the mat ";

You can not. Why do you ask?

1 Like

Because I read that single quote is faster and more “readable” when coding in php.

Like what I understood is better to use :

echo 'Hello, ' . $name . ' how are you? ';

instead of of :

echo "Hello $name how are you?";

That’s why I was wondering how to use {} with single quote

1 Like

The difference in speed is negligible.
It really doesn’t matter, especially with the latest version of PHP.

Out of your two examples, which one do you reckon is more readable? :wink:

1 Like