php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40980 Incorrect output labeled on print_r
Submitted: 2007-04-02 18:29 UTC Modified: 2007-05-25 19:36 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at htmlland dot net Assigned: ezyang (profile)
Status: Closed 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: php at htmlland dot net
New email:
PHP Version: OS:

 

 [2007-04-02 18:29 UTC] php at htmlland dot net
Description:
------------
Shoulden't the return on print_r() be mixed not bool as shown on the documentation page? I say this because the return parameter changes the output returned to a string not a bool.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-05 09:55 UTC] rquadling@php.net
The return parameter was added in PHP4.3.0 and this does change the return type.

As this is the current way print_r() operates, then I agree with you that it should and that the old behaviour should be recorded.
 [2007-04-08 19:42 UTC] ezyang@php.net
"Mixed" is not terribly descriptive though. Maybe...

Index: en/reference/var/functions/print-r.xml
===================================================================
RCS file: /repository/phpdoc/en/reference/var/functions/print-r.xml,v
retrieving revision 1.12
diff -u -r1.12 print-r.xml
--- en/reference/var/functions/print-r.xml	7 Mar 2006 01:12:15 -0000	1.12
+++ en/reference/var/functions/print-r.xml	8 Apr 2007 19:42:19 -0000
@@ -11,7 +11,7 @@
    <refsect1>
     <title>Description</title>
      <methodsynopsis>
-      <type>bool</type><methodname>print_r</methodname>
+      <type>bool/string</type><methodname>print_r</methodname>
       <methodparam><type>mixed</type><parameter>expression</parameter></methodparam>
       <methodparam choice="opt"><type>bool</type><parameter>return</parameter></methodparam>
      </methodsynopsis>

I don't know if we allow that.
 [2007-04-23 13:22 UTC] tayloj1 at uk dot ibm dot com
Ref:  bool print_r ( mixed $expression [, bool $return] ) 

Agree that the return on print_r() should be "mixed" not "bool" as print_r either returns a bool or a string:

     If $return is not specified or set to false then print_r returns
           a bool of TRUE if command is successful  - or -
           a bool of FALSE on error

     If $return == TRUE then print_r either returns 
           a string if command completes OK   - or - 
           a bool FALSE on errors

Correct syntax is:
	
     mixed print_r ( mixed $expression [, bool $return] ) 

Although "mixed" is not very descriptive, this usage is consistent with the rest of the documentation.
 [2007-05-25 19:36 UTC] bjori@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.

Thanks for the patch Edward
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 14:01:31 2025 UTC