#27181 [Bgs]: extra quote marks in example 2.7 in PHP manual lists
| From: | et@php.net | Date: | Sun, 08 Feb 2004 08:53:31 +0000 |
| Subject: | #27181 [Bgs]: extra quote marks in example 2.7 in PHP manual lists | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969358822@lists.php.net to get a copy of this message | ||
ID: 27181
Updated by: et@php.net
Reported By: admin at kcfreepress dot com
Status: Bogus
Bug Type: Documentation problem
Operating System: n/a
PHP Version: Irrelevant
New Comment:
Using quotes only leads to parse errors in strings when not using curly
braces, so "foo $array['bar']" would be incorrect, but that's the only
case you don't use quotes. Using "foo {$array["bar"]}" would be correct
again. See the manual page at http://php.net/types.string
for further
reference.
Previous Comments:
------------------------------------------------------------------------
[2004-02-08 00:55:19] kennyt@php.net
Thanks for your comments, but this is not the case. :)
In general, you must quote the keys used in array operations. If you
don't, you'll get a lot of notices when using E_ALL reporting mode.
(And you are using E_ALL, aren't you?)
So really, the ["key"] notation is correct. [key] is just a hack, and
shouldn't be used. ['key'], of course, would be best. =)
------------------------------------------------------------------------
[2004-02-07 23:18:18] admin at kcfreepress dot com
Description:
------------
Quoted from the PHP Manual (CHM file version, generated: Sun Oct 05
02:13:52 2003)
----------
Example 2-7. Printing data from our form
Hi <?php echo $_POST["name"]; ?>.
You are <?php echo $_POST["age"]; ?> years old.
----------
In order to avoid parse errors, it seems like this should instead
read:
----------
Example 2-7. Printing data from our form
Hi <?php echo $_POST[name]; ?>.
You are <?php echo $_POST[age]; ?> years old.
----------
Thanks!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27181&edit=1