我知道这个问题很难理解,我不知道如何更好地问它,所以我将使用这个代码示例让事情更清楚:
如果我有以下文件:
测试.php:
<?php
include('include.php');
echo myClass::myStaticFunction();
?>
包含.php
<?php
__autoload($classname){
include_once("class/".$classname.".php"); //normally checking of included file would happen
}
?>
类/myClass.php
<?php
class myClass{
public static function myStaticFunction(){
//I want this to return test.php, or whatever the filename is of the file that is using this class
return SOMETHING;
}
?>
神奇的 FILE 常量不正确,它返回 path/to/myClass.php