Syntax

PHP String Interpolation Syntax

In PHP, string interpolation: inserts variables into double-quoted strings — echo "Hi {$name}";

Quick Answer

Syntax
echo "Hi {$name}";
PHPSyntax

String Interpolation

Code example
echo "Hi {$name}";

Inserts variables into double-quoted strings.

Learn More

How to string interpolation in PHP

  1. Open your PHP file or editor.
  2. Copy the example, then replace its sample names and values for your code.

PHP String Interpolation Syntax

Use echo "Hi {$name}";.

Related Syntax References

Frequently asked questions

What is the PHP syntax for string interpolation?

Use this pattern: echo "Hi {$name}";

Can I copy this PHP code example?

Yes. Use Copy code and adapt the example to your program.

Is this PHP syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify