Skip to content
PHP Logo

How can a PHP script display a text or graphic output before execution starts?

To display text or graphic output before a PHP script starts executing, you can use the ob_start() function to buffer the output and then use echo or print statements to display the desired content. This allows you to send output to the browser before any actual processing takes place in the script.

php
<?php
ob_start();
echo "This text will be displayed before any other output";
// Other PHP code here
ob_end_flush();
?>