|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-07-03 07:22 UTC] roland at nextendweb dot com
Description: ------------ http://sandbox.onlinephpfunctions.com/code/08eee50202cb2e8ce5b6e849aacb7c5bf37de4ba Test script: --------------- <?php class a { private static $bug = 'World'; public static function parse_output($buffer) { $buffer = str_replace('there', self::$bug, $buffer); self::$bug = 'What?'; return $buffer; } } ob_start('a::parse_output'); echo "Hello there"; $content = ob_get_contents(); ob_clean(); echo $content; ob_end_flush(); Expected result: ---------------- Hello World Actual result: -------------- Hello What? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Well, it makes sense. So I should use the output callback phase parameter to check. Could you tell me which is the phase which runs only once when the output buffer closed completely? class a { private static $bug = 'World'; public static function parse_output($buffer, $phase) { if ( $phase & PHP_OUTPUT_HANDLER_FINAL ){ $buffer = str_replace('there', self::$bug, $buffer); self::$bug = 'What?'; } return $buffer; } }