ページ名に基づいてdivをトリガーするにはどうすればよいですか?ページ名に基づいてdivをトリガーする方法
ページ名に基づいて同じdivに異なるPHP応答を表示したいと思います。
私はのようなものを考えています:
<html lang="en">
<head>
<?php include("includes/head.php");?>
</head>
<body>
<?php include("includes/top");?>
<div id= content>
<?php include("includes/content.php");?>
</div>
<?php include("includes/footer");?>
</body>
</html>
私はすべてのページに、この構造を使用したいと私はDIVをしたい:全てのページの構造があるためです
<?php
$pageName = basename($_SERVER['PHP_SELF']);
if ($pageName == 'index.php') {
include("http://website/reponse-from-script-1);
} else if ($pageName == 'index2.php') {
include("http://website/reponse-from-script-2);
} else if ($pageName == 'index3.php') {
include("http://website/reponse-from-script-3);
}
?>
ページのタイトルに基づいて変更する "コンテンツ"。
ご協力いただければ幸いです。
はありがとう
--------- UPDATE 2 ---------- は、これは私のコードです:
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("includes/head.php");?>
</head>
<body>
<?php include("includes/scripts.php");?>
<div id="wrapper">
<?php include("includes/navandsidebar.php");?>
<?php include("includes/main-menu.php");?>
<?php include("includes/secondary-menu.php");?>
<?php include("includes/working-space.php");?>
</div>
</body>
</html>
このコードはすべてのためにありますこの2つのセクションが変更されていることを除いて、私はdivを「内部的に」トリガーしたいのです。以下のように、
<?php include("includes/secondary-menu.php");?>
<?php include("includes/working-space.php");?>
あなたはおそらく魔法の定数である '__FILE__'を使うことができます。[http://php.net/manual/en/language.constants.predefined.php] – jkys
これを使ったことはありません。それを見てください。ありがとうございました – MisterNubb