How can mixing PHP and HTML impact the readability and maintainability of code?

Mixing PHP and HTML can impact the readability and maintainability of code by making it harder to separate logic from presentation. To improve this, it's recommended to use a templating engine like Twig or Blade that allows you to cleanly separate PHP logic from HTML markup.

<?php
// Using a templating engine like Twig
require_once 'vendor/autoload.php';

$loader = new \Twig\Loader\FilesystemLoader('templates');
$twig = new \Twig\Environment($loader);

echo $twig->render('index.html', ['name' => 'John Doe']);
?>