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.
我有一个测试,我必须比较 current_time 以确定另一个时间。除了使用模拟(即返回我指定时间的另一种方法)之外,还有另一种方法可以将系统时间临时更改为指定时间以进行另一次测试。我想要一种让 time() 返回另一个值的简单方法。
如果你安装了 runkit 扩展,你可以使用 runkit_function_redefine 函数来归档它。
来自 PHP 文档:为了覆盖内部函数,您必须在 php.ini 中启用 runkit.internal_override 设置。
然后您可以分配一个代码字符串作为函数体。
问候