-2
如果檢測到特殊的URL,我的想法是將多個鏈接切換到CSS文件。但是我遇到了麻煩:我的代碼在第一個if..else語句中僅包含css。它不依賴於URL。通過PHP將鏈接切換到CSS
這是我的代碼。 http://pastebin.com/Jm3QFDmH
從引擎收錄
<?php
// get first folder in URL
$f_folder = substr(substr($_SERVER["REQUEST_URI"],1), 0, strpos(substr($_SERVER["REQUEST_URI"],1), "/"));
//get full directory structure from URL for current page
$full_path = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
//css for account
if ($f_folder='account') {
?>
<link rel="stylesheet" href="/mainstyle/common.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="/mainstyle/account.css" type="text/css" charset="utf-8" />
<?php
} elseif ($f_folder='signin'||$f_folder='signup'||$full_path='/account/resetPassword'||$full_path='/account/logout') {
?>
<link rel="stylesheet" href="/mainstyle/login-signup.css" type="text/css" charset="utf-8" />
<?php
} else {
?>
<link rel="stylesheet" href="/mainstyle/common.css" type="text/css" charset="utf-8" />
<?php
}
?>
哪裏是錯誤的端口? 7
嘗試打印'$ f_folder',看看是否有問題。 – 2012-07-08 08:14:13
@NikolaK。我試過了,它工作 – treng 2012-07-08 08:14:47
如果應該是︰if($ f_folder =='account') – Alf 2012-07-08 08:15:46