|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-11-09 10:32 UTC] clement dot barbaza at gmail dot com
Description: ------------ Hello, I found an error in the documentation Strings : http://php.net/manual/en/language.types.string.php There is a problem on the documentation : echo "He drank some juice made of ${juice}s."; Instead, it has to be : echo "He drank some juice made of {$juice}s."; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 15:00:01 2025 UTC |
Hi, Thank you for your quick reply! I know there are 2 syntaxes to express the same thing, but in this case, it doesn't work :( I simply created a file and inserted the documentation code : <?php $juice = "apple"; echo "He drank some $juice juice.".PHP_EOL; // Invalid. "s" is a valid character for a variable name, but the variable is $juice. echo "He drank some juice made of $juices."; // Valid. Explicitly specify the end of the variable name by enclosing it in braces: echo "He drank some juice made of ${juice}s."; Here's the result: php -f index.php He drank some apple juice. PHP Notice: Undefined variable: juices in index.php on line 7 Notice: Undefined variable: juices in index.php on line 7 He drank some juice made of .He drank some juice made of apples.% I hope it will help you to check this documentation error.