Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一个文件中有一个最终类及其私有/公共静态方法,并希望在另一个文件中访问其私有静态方法。我可以这样做吗?这是合法的访问吗?
你总是可以尝试在运行时通过反射来改变它
$method = new ReflectionMethod('FinalClassName', 'staticMethodName'); $method->setAccessible(true); $method->invoke(null, $arg1, $arg2, $etc);