How can the output in PHP, such as temperature readings, be formatted and centered within an HTML page?

To format and center output in PHP within an HTML page, you can use CSS styles to center the text and format it as needed. You can create a CSS class that centers the text and then apply that class to the output in your PHP code.

<!DOCTYPE html>
<html>
<head>
    <style>
        .center {
            text-align: center;
        }
    </style>
</head>
<body>
    <?php
        $temperature = 25;
        echo '<div class="center">Temperature: ' . $temperature . '°C</div>';
    ?>
</body>
</html>