Reputation: 43627
We have urls:
http://site.com/movies/posters/ID.html
http://site.com/movies/posters/fixed/ID.html
How do I know if /posters/fixed/
is present in the current url (on opened page)?
Like:
if ("/posters/fixed/" present) {
$match_fixed = true;
}
Thanks.
Upvotes: 0
Views: 5935
Reputation: 29669
If you want to check if a file exists, then you can simply call file_exists()
.
if (file_exists("./movies/posters/fixed/ID.html") && is_file("./movies/posters/fixed/ID.html")) {
$match_fixed = true;
}
I take the PHP file is copied in the server root directory.
If you want to verify the URL used to access the files you reported (assuming they are really PHP files, and you put the code inside them to verify the URL used to access them, then the following code works:
if (strpos($_SERVER['REQUEST_URI'],"/posters/fixed/") === 0) {
$match_fixed = true;
}
If you meant something else, then extend the question so it's clearer what you mean.
Upvotes: 1
Reputation: 70460
if(strpos($_SERVER['REQUEST_URI'],"/movies/posters/fixed/")===0){
//true
}
Upvotes: 8
Reputation: 3364
if (preg_match("//posters/fixed/", $_SERVER['REQUEST_URI'])) ...
Upvotes: 3