Most egy mini MVC (Modell View Controll) elvel alapuló weboldalt készítűnk PHP segítségével.
Ami kell:
- index.tpl.html
- index.php
index.tpl.html tartalma:
<html>
index.php tartalma:
<head>
<title>(CÍM)</title>
</head>
<body>
<div id='tart'>(TARTALOM)</div>
</body>
</html>
<?php
A kimenet:
$cim="Cím";
$tartalom="Tartalom";
$oldal=file_get_contents("index.tpl.html");
$oldal=str_replace("(CÍM)",$cim,$oldal);
$oldal=str_replace("(TARTALOM)",$tartalom,$oldal);
print $oldal;
?>
<html>
<head>
<title>Cím</title>
</head>
<body>
<div id='tart'>Tartalom</div>
</body>
</html>