php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65826 ob_list_handlers: outdated return values & examples
Submitted: 2013-10-03 12:53 UTC Modified: 2024-01-07 13:45 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: ca2 at lapage dot com Assigned: girgias (profile)
Status: Closed Package: Output Control
PHP Version: 5.5.4 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ca2 at lapage dot com
New email:
PHP Version: OS:

 

 [2013-10-03 12:53 UTC] ca2 at lapage dot com
Description:
------------
---
From manual page: http://www.php.net/function.ob-list-handlers#refsect1-function.ob-list-handlers-returnvalues
---

The "Return Values" section says:
###
This will return an array with the output handlers in use (if any). If output_buffering is enabled or an anonymous function was used with ob_start(), ob_list_handlers() will return "default output handler". 
###

It should say:
###
This will return an array with the output handlers in use (if any).
* If output_buffering is enabled, or ob_start was used without an output_callback, the handler is "default output handler".
* If the output_callback was an anonymous function specified by create_function(), the handler is an empty string. (In PHP 5.4 and below it is  "default output handler".)
* If the output_callback was an anonymous function specified as a closure, the handler is "Closure::__invoke".
###

I tested on Win8x86 with PHP 5.5.4.
I tested on Linux with PHP 5.4.20 and PHP 5.3.27.

Test script:
---------------
if (ini_get('output_buffering')) {
  print "using output_buffering=on\n";
  print_r(ob_list_handlers());
  ob_end_flush();
} else {
  ob_start("ob_gzhandler");
  print "ob_gzhandler\n";
  print_r(ob_list_handlers());
  ob_end_flush();

  ob_start(create_function('$string', 'return $string;'));
  print "anonymous function / create function\n";
  print_r(ob_list_handlers());
  ob_end_flush();

  ob_start(function($string) { return $string; });
  print "anonymous function / closure\n";
  print_r(ob_list_handlers());
  ob_end_flush();
}

Expected result:
----------------
[output if the doc was right]

# php --version

PHP 5.5.4 (cli) (built: Sep 18 2013 13:04:23) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies

# php -d output_buffering=on test.php

using output_buffering=on
Array
(
    [0] => default output handler
)

# php -d test.php

ob_gzhandler
Array
(
    [0] => ob_gzhandler
)
anonymous function / create function
Array
(
    [0] => default output handler
)
anonymous function / closure
Array
(
    [0] => default output handler
)


Actual result:
--------------
[correct output]

# php --version

PHP 5.5.4 (cli) (built: Sep 18 2013 13:04:23) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies

# php -d output_buffering=on test.php

using output_buffering=on
Array
(
    [0] => default output handler
)

# php -d test.php

ob_gzhandler
Array
(
    [0] => ob_gzhandler
)
anonymous function / create function
Array
(
    [0] => 
)
anonymous function / closure
Array
(
    [0] => Closure::__invoke
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-03 12:59 UTC] ca at lapage dot com
The Examples should also be changed the script and result I provided in the report. (Without the version report and command lines.)
 [2013-10-03 16:12 UTC] ca2 at lapage dot com
Related Doc Bug #62019 for ob_get_status()
 [2017-01-28 12:26 UTC] cmb@php.net
-Package: Documentation problem +Package: Output Control
 [2024-01-07 13:45 UTC] girgias@php.net
-Status: Open +Status: Closed -Operating System: win32 +Operating System: -Assigned To: +Assigned To: girgias
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 09:01:27 2024 UTC