我想在我的php中使用测试条件中的当前文件名.
例如:
if ('current page' == editprofile.php) {
// some code;
}
Run Code Online (Sandbox Code Playgroud)
我该如何测试?
谢谢
将basename()与__FILE__常量结合使用.
if(basename(__FILE__) == "editprofile.php") {
// some code;
}
Run Code Online (Sandbox Code Playgroud)
stripos如果您正在寻找原始速度,它甚至可能更快使用......
if(stripos(__FILE__, "editprofile.php") !== false) {
// Some Code
}
Run Code Online (Sandbox Code Playgroud)