xref: /PHP-7.4/tests/lang/bug30578.phpt (revision 782352c5)
1--TEST--
2Bug #30578 (Output buffers flushed before calling __desctruct functions)
3--FILE--
4<?php
5
6error_reporting(E_ALL);
7
8class Example
9{
10    function __construct()
11    {
12        ob_start();
13        echo "This should be displayed last.\n";
14    }
15
16    function __destruct()
17    {
18        $buffered_data = ob_get_contents();
19        ob_end_clean();
20
21        echo "This should be displayed first.\n";
22        echo "Buffered data: $buffered_data";
23    }
24}
25
26$obj = new Example;
27
28?>
29--EXPECT--
30This should be displayed first.
31Buffered data: This should be displayed last.
32