php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62796 Third parameter for ob_start incorrectly documented
Submitted: 2012-08-11 07:59 UTC Modified: 2013-09-26 21:21 UTC
Votes:2
Avg. Score:3.5 ± 1.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: benrwhite at gmail dot com Assigned:
Status: Duplicate Package: Documentation problem
PHP Version: 5.4.5 OS: Archlinux (Probably all)
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: benrwhite at gmail dot com
New email:
PHP Version: OS:

 

 [2012-08-11 07:59 UTC] benrwhite at gmail dot com
Description:
------------
The manual page: http://www.php.net/function.ob-start states that the third parameter is set to true by default and changing it to false prevents any buffer created using this function from being erasable.

After some confusion in use of this function, I dug into the code for the master php-src branch and discovered that the function instead now seems to expect a bitwise combination of flags. The following constant definitions should probably be documented under the output handler predefined constants -

  40 #define PHP_OUTPUT_HANDLER_CLEANABLE    0x0010
  41 #define PHP_OUTPUT_HANDLER_FLUSHABLE    0x0020
  42 #define PHP_OUTPUT_HANDLER_REMOVABLE    0x0040
  43 #define PHP_OUTPUT_HANDLER_STDFLAGS             0x0070

and referred to under the documentation for the third parmeter of ob_start.

Test script:
---------------
<?php

// ******** Part 1 

ob_start(null,0,PHP_OUTPUT_HANDLER_STDFLAGS);
echo 'A';
$test = ob_get_contents();
ob_end_clean();

echo 'B';
echo $test;

// ******** Part 2 (works on 5.3)

ob_start(null,0,true);
echo 'A';
$test = ob_get_contents();
ob_end_clean(); //throws warning

echo 'B';
echo $test;




Expected result:
----------------
The first part is using undocumented flags, so undefined?
The second part should output string 'BA' according to the documentation.

Actual result:
--------------
 on 5.4.5 -
The first part outputs 'BA'
The second part outputs 'ABA'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-24 02:29 UTC] alan at roojs dot com
Not sure if this is only a documentation problem - It seems to be a BC break. - 
it breaks previously working code on upgrade.
 [2013-09-26 14:48 UTC] mike@php.net
Sure. In 5.4.0

See bug #64977
 [2013-09-26 21:21 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 [2013-09-26 21:21 UTC] aharvey@php.net
Marking as a dupe of bug #64977, since that has more detail.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC