Are there any best practices for structuring PHP code when handling button click events for outputting HTML text?

When handling button click events for outputting HTML text in PHP, it is best practice to separate your logic from your presentation by using a templating system like PHP's built-in `echo` or `printf` functions. This helps maintain clean and readable code by keeping HTML separate from PHP logic.

<?php
if(isset($_POST['submit'])) {
    $name = $_POST['name'];
    $message = "Hello, $name!";
    // Output the HTML text using PHP echo
    echo "<p>$message</p>";
}
?>

<form method="post">
    <input type="text" name="name" placeholder="Enter your name">
    <input type="submit" name="submit" value="Submit">
</form>