How to insert variable into a string in PHP

1 Answer

0 votes
$n = 5;
$s = "The number {$n} is ...";
echo $s . "\n";


$lang = "PHP";
$s = "The language {$lang} is ...";
echo $s;

  
  
  
/*
run:
  
The number 5 is ...
The language PHP is ...
  
*/

 



answered Mar 30, 2022 by avibootz
...