動的な Web サイトを作成しようとしています。index.php には、Web サイトのコンテンツ領域に次のコードが含まれています。
<?PHP
// if undefined then define
if(!$od || $od == ""){
$od = "news";
}
// check if exists prep
$link = 'incs'."/".$od.$ext;
flush();
$fp = fopen($link, "r");
// check if inclusion file not exists then return error
if (!$fp) {
echo "An error has ocurred while processing your request. The file linked as ?od=".$od." does not appear to exist.";
}
// if exists then return parse
else {
fclose($fp);
include 'incs'."/".$od.$ext;
}
echo '</body>'."\n";
echo '</html>'."\n";
?>
サイト全体に、登録、ログインなどのページへのさまざまなリンクもあります。これらのリンクは、?od=register、?od=login などのページを指しています。
Web サイトは、ニュースのデフォルト ファイルを取得し、それを Web サイトのコンテンツ セクションに表示しますが、[登録] をクリックすると、アドレス バーの URL が /?od=register に変わりますが、デフォルトのニュースはそのままですコンテンツセクション、上記のコードにエラーはありますか? それとも、何かが足りないのですか?
PS$ext
は構成ファイルで として定義されておりinc.php
、インデックス ページの上部に含まれています。