Utilisation de PHP comme système de template
Débutant que je suis ! :lol:
En cherchant sur le web et en bidouillant pour faire des templates, j'ai trouvé ceci :
fichier gabarit.tpl :
Code:
1 2 3 4 5 6 7 8
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head><title><?php echo $titre; ?></title></head>
<body>
<h1><?php echo $titre; ?></h1>
<p><?php echo $message; ?><p>
</body>
</html> |
fichier index.php :
Code:
1 2 3 4 5
| <?php
$titre = 'Le titre de la page';
$message = 'Voici le message a placer dans le gabarit';
include 'gabarit.tpl';
?> |
Quand on lance index.php, on obtient :
Le titre de la page
Voici le message a placer dans le gabarit
Trop simple, non ? :D