我們的網址:檢查當前URL
http://site.com/movies/posters/ID.html
http://site.com/movies/posters/fixed/ID.html
我怎麼知道/posters/fixed/
是存在於當前URL(打開網頁)?
像:
if ("/posters/fixed/" present) {
$match_fixed = true;
}
感謝。
我們的網址:檢查當前URL
http://site.com/movies/posters/ID.html
http://site.com/movies/posters/fixed/ID.html
我怎麼知道/posters/fixed/
是存在於當前URL(打開網頁)?
像:
if ("/posters/fixed/" present) {
$match_fixed = true;
}
感謝。
if(strpos($_SERVER['REQUEST_URI'],"/movies/posters/fixed/")===0){
//true
}
如果(的preg_match( 「//海報/固定/」,$ _ SERVER [ 'REQUEST_URI']))...
如果您要檢查文件是否存在,那麼你可以簡單致電file_exists()
。
if (file_exists("./movies/posters/fixed/ID.html") && is_file("./movies/posters/fixed/ID.html")) {
$match_fixed = true;
}
我把PHP文件在服務器根目錄下複製。
如果您想驗證用於訪問您報道(假設他們是真正的PHP文件的文件的URL,你把它們內部的代碼以驗證用於訪問這些網址,然後下面的代碼工作:
if (strpos($_SERVER['REQUEST_URI'],"/posters/fixed/") === 0) {
$match_fixed = true;
}
如果你的意思是別的,那就延長這個問題,這樣就可以更清楚地表達你的意思了。