php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #27181 extra quote marks in example 2.7 in PHP manual lists
Submitted: 2004-02-07 23:18 UTC Modified: 2004-02-08 03:53 UTC
From: admin at kcfreepress dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: admin at kcfreepress dot com
New email:
PHP Version: OS:

 

 [2004-02-07 23:18 UTC] 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!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-08 00:55 UTC] 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-08 03:53 UTC] et@php.net
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 12:01:31 2025 UTC