if (FILE == '')这个代码用意是什么,什么情况下FILE 会是空的

WBOY
Release: 2016-06-23 13:07:58
Original
1215 people have browsed it

ecshop中的init.php文件中有这样一段代码

if (__FILE__ == '')  //这行没想明白,有写的必要吗,当前文件的绝对路径什么情况下会是空的??
{
    die('Fatal error code: 0');
}


回复讨论(解决方案)

__FILE__ 表示当前文件的文件名
不可能为空



这么写应该有他的用意,只是没想明白为什么这么写

__FILE__ 表示当前文件的文件名
不可能为空



ecshop应该不会无缘无故写这么一句判断,我想应该有什么必要性


文件名也有可能是空的

如果非要说什么情况为空  你把它的值改成 空了,那它不就空了,除非不能改

如果非要说什么情况为空  你把它的值改成 空了,那它不就空了,除非不能改

魔术常量应该不能赋值吧,你说的是文件名改空吧


文件名也有可能是空的

也有可能是路径


文件名也有可能是空的

也有可能是判断__FILE__是否存在,也就是兼容性判断,但感觉好像也没这个必要,__FILE__很早的PHP版本就 有了
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!