PHP: |
, . , . "data", . , main.html, about.html, works.html contacts.html. ( "data") index.php, .
<?PHP
// php: -
//
//
$max = 0;
//
$page = main;
// *.txt "data"
foreach (glob("data/*.html") as $filename) $max++;
// $max
// ,
// ...
// $_GET['page']
if (isset($_GET['page']) and trim($_GET['page']) != "") {
// $page
$page = trim($_GET['page']);
}
// $page
$file = "data/".$page.".html";
// , , ?
if (file_exists($file)) {
// ,
$title = " ".$page.".html";
$content = file_get_contents($file);
}
else {
// ,
$title = " ".$page.".html ";
$content = "<h3>".$title."</h3>";
}
?>
<html>
<head>
<title><?PHP echo $title; ?></title>
</head>
<body>
<a href="?page=main">main</a><br>
<a href="?page=about">about</a><br>
<a href="?page=works">works</a><br>
<a href="?page=contacts">contacts</a>
?></h1>
<?PHP echo $content; ?>
</body>
</html>
: | PHP |