Bug #77130 [Nab]: Documentation error
| From: | clement dot barbaza at gmail dot com | Date: | Fri, 09 Nov 2018 12:59:03 +0000 |
| Subject: | Bug #77130 [Nab]: Documentation error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16129@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77130&edit=1
ID: 77130
User updated by: clement dot barbaza at gmail dot com
Reported by: clement dot barbaza at gmail dot com
Summary: Documentation error
Status: Not a bug
Type: Bug
Package: Documentation problem
Operating System: Mac OS 10.14.1
PHP Version: 7.2.12
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2018-11-09 10:39:40] sjon at Hortensius dot net
actually both are correct, so why do you think it has to be one, not the other?
------------------------------------------------------------------------
[2018-11-09 10:39:11] bwoebi@php.net
This is valid syntax. Though you usually see the latter variant, it's just two syntaxes to
express the same thing.
------------------------------------------------------------------------
[2018-11-09 10:32:41] 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.";
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77130&edit=1