php / doc-en

English PHP documentation
488 stars 724 forks source link

Using ${var} in strings is deprecated, use {$var} #2465

Open nickstrlnkv opened 1 year ago

nickstrlnkv commented 1 year ago

The example here is incorrect. Chapter "Simple syntax" When you use it, it gives an error

<?php $juice = "apple"; // Valid. Explicitly specify the end of the variable name by enclosing it in braces: echo "He drank some juice made of ${juice}s."; ?> Without error should write: <?php $juice = "apple"; // Valid. Explicitly specify the end of the variable name by enclosing it in braces: echo "He drank some juice made of {$juice}s."; ?>

Girgias commented 1 year ago

See #2000 which fixes this.

nickstrlnkv commented 1 year ago

Maybe should add .<?php $juice = "apple"; // Valid. Explicitly specify the end of the variable name by enclosing it in braces: echo "He drank some juice made of ${juice}s.".PHP_EOL; ?> to this line. Not to be misleading, or am I wrong?