php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45525 Object Closure as
Submitted: 2008-07-16 05:25 UTC Modified: 2008-07-17 09:55 UTC
From: david at grudl dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2008-07-16 (snap) OS: windows xp
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: david at grudl dot com
New email:
PHP Version: OS:

 

 [2008-07-16 05:25 UTC] david at grudl dot com
Description:
------------
Lambda functions and closures are AWESOME!

But they are not still supported as ob_start() argument.



Reproduce code:
---------------
function redirect($file)
{
    $handle = fopen($file, 'w');
    ob_start(function($buffer) use ($handle) {
        fwrite($handle, $buffer);
    });
}

redirect('output.html');
echo 'Hello World!'; 

Expected result:
----------------
Should work

Actual result:
--------------
Fatal error: ob_start(): No method name given: use ob_start(array($object,'method')) to specify instance $object and the name of a method of class Closure to use as output buffer.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-16 07:23 UTC] derick@php.net
Dmitry, could you have a look please?
 [2008-07-17 09:55 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC