私のメインページのタイトルは取得していますが、内部ページ(可変ポスト)を取得する場合は機能しません。PHPでページタイトルを動的に取得する方法
$path=$_SERVER['PHP_SELF'];
$page_title=basename($path);
switch($page_title){
case 'index.php':
$title="Welcome to the the website";
$description="description goes here";
break;
case 'about.php':
$title="Welcome to the the website";
$description="somehtinfd";
break;
case 'career.php':
$title="Welcome to the the website";
$description="ome textr";
break;
/*IT's NOT WORKING HERE*/
case 'post.php?post_id=1':$title="graphics design services";
$description= "about ";
break;
}
$ _SERVER ['PHP_SELF']は、URLのクエリ文字列を返しません。 post.php – manian
'' post.php?post_id = 1''というファイル名でしか試してはいけません - それを比較しようとしている '$ page_title'の値を見ましたか? – Quentin
こんにちは兄どのように私はこのタイプの値を得ることができます –