ob_flush example


    }

    /** * Send an event to the browser. */
    private function sendEvent(string $event, array $data): void
    {
        echo "event: {$event}\n";
        echo 'data: ' . json_encode($data) . "\n\n";

        ob_flush();
        flush();
    }
}
register_shutdown_function(function D): void {
            $lastError = error_get_last();
            if (!\is_array($lastError)) {
                return;
            }

            switch ($lastError['type']) {
                case E_ERROR:
                case E_PARSE:
                case E_CORE_ERROR:
                    ob_clean();
                    ob_flush();
                    http_response_code(200);
                    $message = 'Error<br><br>' . $lastError['message'] . '<br><br>File:' . str_replace('/', '/ ', $lastError['file']);
                    echo json_encode(['success' => false, 'error' => $message]);
            }
        });
    }

    /** * Gets an array of plugins that are in Safe Mode * * @param array<Plugin> $plugins * * @return array<Plugin> */
echo "\r\n";
        echo 'Here the body';
        exit;

    case '/404':
        header('Content-Type: application/json', true, 404);
        break;

    case '/404-gzipped':
        header('Content-Type: text/plain', true, 404);
        ob_start('ob_gzhandler');
        @ob_flush();
        flush();
        usleep(300000);
        echo 'some text';
        exit;

    case '/301':
        if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) {
            header('Location: http://127.0.0.1:8057/302', true, 301);
        }
        break;

    
Home | Imprint | This part of the site doesn't use cookies.