1

私のコード、キーワードの設定、ページの説明とタイトルについて助けてもらいたいです。

私の head.php (index.php に含まれています):

<?php 
$current = $SERVER_[REQUEST_URI];
$home = "/#!/page_HOME";
if($current==$home) {
  $title = "Example.com || Home";
  $keywords = "some words";
  $description = "description text";
}   
?>

私のウェブサイトは、次のような「奇妙な」URL を使用していますhttp://example.com/index.php#!/page_HOME。これは、さまざまなページをロードするための CSS と jQuery のトリックを備えた Web ページです。

ここで、メニュー リンクをクリックして、ページのキーワード、説明、およびタイトルを変更したいと思います。

index.php では、menu および include ステートメントは次のようになります。

**link in menu:** 
<a href="#!/page_HOME">Home</a>
**include in webpage:** 
<li id="page_HOME">
    <a href="#!/page_SPLASH" class="close"></a>  
    <?php include('home.html'); ?>
</li>

などでこれをやろうとしましたが$SERVER_[REQUEST_URI]、管理できません。

この「問題」の解決を手伝ってください

4

1 に答える 1

0

parse_url();を使用して、アンカー フラグメント (# の後のすべて) を取得できます。参照: http://php.net/parse_url

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$urlFragment = parse_url( $url, PHP_URL_FRAGMENT );

switch( $urlFragment )
{
    case '!/page_SPLASH':
        $title = "Example.com || Splash";
        $keywords = "splash content";
        $description = "splash description text";
        break;

    /* define more pages here */

    case '!/page_HOME': /* no break; intended */
    default:
        $title = "Example.com || Home";
        $keywords = "some words";
        $description = "description text";
        break;
}
于 2013-09-13T14:05:06.547 に答える