How can the EVA principle be applied to improve the structure of PHP code for HTML output?
Issue: The EVA principle (Separation of Concerns - SoC, Single Responsibility Principle - SRP, and Don't Repeat Yourself - DRY) can be applied to improve the structure of PHP code for HTML output by separating the logic from the presentation. This can be achieved by creating separate files for HTML templates and using PHP to dynamically populate these templates with data. Code snippet:
<?php
// index.php
// Data to be displayed in HTML
$data = [
'title' => 'Welcome to our website',
'content' => 'This is some sample content',
'footer' => 'Copyright © 2022'
];
// Include HTML template file
include 'template.php';
?>
```
```php
<!-- template.php -->
<!DOCTYPE html>
<html>
<head>
<title><?php echo $data['title']; ?></title>
</head>
<body>
<h1><?php echo $data['title']; ?></h1>
<p><?php echo $data['content']; ?></p>
<footer><?php echo $data['footer']; ?></footer>
</body>
</html>