在继续之前,PHP是否等待文件系统操作(如file_put_contents)? [英] Does PHP wait for filesystem operations (like file_put_contents) to complete before moving on?

查看:191
本文介绍了在继续之前,PHP是否等待文件系统操作(如file_put_contents)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于PHP如何处理文件系统操作的问题。我正在运行这个代码,这个代码依赖于在被使用之前创建的一个文件,当我运行这个代码的时候,它变成了一个竞争条件 - 有时候它会工作,文件被创建,php代码使用它,有时它失败。

I have a question about how PHP handles filesystem operations. I'm running this code that depends on a file being created before it gets used, and it feels like when I run the code it becomes a race condition - sometimes the it works, the file is created and php code uses it, sometimes it fails.

所以我想知道php是如何处理文件系统操作的,它是在后台发送还是等到操作完成?是的,除非你打开一个文件句柄,然后将其设置为非阻塞模式:

So I was wondering how php handles filesystem operations, does it send it off in the background or does it wait till the operation complete?

推荐答案

这篇关于在继续之前,PHP是否等待文件系统操作(如file_put_contents)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆