何时包括为静态函数处理的


when are includes processed for static functions?

考虑以下内容:

class MyClass { 
    public static function MyIncludingMethod() {
        include_once("includes.php");
    }
    public static function MyOtherMethod() {
    }
}

假设这是有效的,includes.php什么时候会被包含?

选项1)当包含所有这些的php文件包含时

选项2)当MyClass::MyIncludengMethod()被调用时

选项3)当调用MyClass中的任何内容时,即使MyClass::MyIncludingMethod()尚未调用

includes.php:

<?php
  touch('i_was_called.txt');
?>

结果

一切如预期:)