What are the potential pitfalls of mixing design elements with PHP code?

Mixing design elements with PHP code can lead to messy and hard-to-maintain code. It can also make it difficult to separate the presentation layer from the logic layer, which can hinder code reusability and scalability. To avoid these pitfalls, it's recommended to use a templating engine like Twig or Blade to keep the design elements separate from the PHP logic.

// Example using Twig templating engine
require_once 'vendor/autoload.php';

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

$template = $twig->load('index.html');
echo $template->render(['title' => 'Home Page', 'content' => 'Welcome to our website']);