ob_get_contents

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return the contents of the output buffer
<?php ob_get_contents(): string|false
<?php         include __DIR__."/../../resources/views/components/$view.php";



        return tap(ob_get_contents(), function () {

            ob_end_clean();

        });

    }
<?php         ob_start();

        eval(Str::of($this->compiler->compileString($blade))->remove(['<?php', '?>']));

        $output = ob_get_contents();

        ob_end_clean();



        $this->assertSame($expectedOutput, $output);
<?php         ob_start();

        eval(Str::of($this->compiler->compileString($blade))->remove(['<?php', '?>']));

        $output = ob_get_contents();

        ob_end_clean();



        $this->assertSame($expectedOutput, $output);
<?php         include sprintf('%s/../../resources/views/%s.php', __DIR__, $path);



        $contents = ob_get_contents();



        ob_clean();
<?php             $response = $gateway->handle($request);



            $output = ob_get_contents();



            ob_end_clean();
<?php         ob_start();

        imagejpeg($this->image->getCore(), null, $this->quality);

        $this->image->mime = image_type_to_mime_type(IMAGETYPE_JPEG);

        $buffer = ob_get_contents();

        ob_end_clean();



        return $buffer;
<?php         imagesavealpha($resource, true);

        imagepng($resource, null, -1);

        $this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG);

        $buffer = ob_get_contents();

        ob_end_clean();



        return $buffer;
<?php         ob_start();

        imagegif($this->image->getCore());

        $this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF);

        $buffer = ob_get_contents();

        ob_end_clean();



        return $buffer;
<?php         imagesavealpha($this->image->getCore(), true);

        imagewebp($this->image->getCore(), null, $this->quality);

        $this->image->mime = defined('IMAGETYPE_WEBP') ? image_type_to_mime_type(IMAGETYPE_WEBP) : 'image/webp';

        $buffer = ob_get_contents();

        ob_end_clean();

        

        return $buffer;
<?php         ob_start();

        imagebmp($this->image->getCore());

        $this->image->mime = defined('IMAGETYPE_BMP') ? image_type_to_mime_type(IMAGETYPE_BMP) : 'image/bmp';

        $buffer = ob_get_contents();

        ob_end_clean();

        

        return $buffer;
<?php         ob_start();

        $result->getRoute()->getHandler()();

        $echoed = ob_get_contents();

        ob_end_clean();



        self::assertSame($message, $echoed);
<?php             ], new Context('abc', time(), 'abc', 'abc'));

            $this->fail('No exception was thrown');

        } catch (Timeout $e) {

            $logs = ob_get_contents();

            self::assertStringContainsString('This is a log message', $logs);

        }

    }