【问题标题】:What happens if file_put_contents can't lock?如果 file_put_contents 无法锁定会怎样?
【发布时间】:2017-12-08 12:03:19
【问题描述】:

假设多人使用命令同时写入同一个文件

file_put_contents('file.txt', 'This is an example', LOCK_EX);

是否有可能一个人无法写入文件,因为函数file_put_contents 必须等待太长时间才能锁定文件?函数会抛出异常,还是会出现如下错误:

“致命错误:超出最大执行时间 .. 秒”

【问题讨论】:

标签: php file


【解决方案1】:

该错误看起来像是脚本的执行超时(执行脚本的时间超出了配置的值,因为进程正在等待获取),将有默认超时,您可以在 php 中检查默认的 max-execution-time .ini 文件

max-execution-time=30

您可以调整超时并检查 http://php.net/manual/en/function.set-time-limit.php 或 max-execution-time

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 2011-04-27
    • 1970-01-01
    • 2019-05-13
    • 1970-01-01
    相关资源
    最近更新 更多