php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44948 heredoc and nowdoc examples are incorrect
Submitted: 2008-05-08 17:57 UTC Modified: 2008-05-09 11:59 UTC
From: stepheneliotdewey at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
 [2008-05-08 17:57 UTC] stepheneliotdewey at gmail dot com
Description:
------------
The examples given in the manual for heredoc and nowdoc are incorrect.

On this page:
http://www.php.net/manual/en/language.types.string.php

Example 2 says that it will print:

My name is "MyName". I am printing some foo.
Now I am printing some Bar2.
This should print a capital 'A': \x41

When actually it prints:

My name is "MyName". I am printing some Foo. Now, I am printing some Bar2. This should print a capital 'A': A

(There are 2 differences here: Foo should be capitalized, and \x41 should be printed as A instead.)

Example 3 says that it will print:

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41

When actually I'm pretty sure that it should print:

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': x41

(I have not tested the problem with Example 3 because I only have PHP 5.1. The only error in Example 3 is that there should not be a slash before the x, because there is not one in the example. Alternatively, you could add a slash in the example).

Also, in both cases, you are preserving the line breaks, but you should clarify that the line breaks would not be displayed in an HTML context.



Reproduce code:
---------------
n/a see above

Expected result:
----------------
n/a see above

Actual result:
--------------
n/a see above

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-09 11:59 UTC] rquadling@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 15:00:02 2026 UTC