- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建这个路径的文件:/var/logs/filename.fileextension。但是我没有创建文件我有错误 ->无法触摸“/var/logs/file.txt”。
我的代码:
$fs=new Filesystem();
$fs->touch('/var/logs/file.txt');
最佳答案
touch() sets access and modification time for a file. The current time is used by default. You can set your own with the second argument. The third argument is the access time:
因此 touch 不会根据文档创建新文件。
阅读http://symfony.com/doc/current/components/filesystem.html
如果你想创建一个文件你需要使用函数dumpFile();
dumpFile() allows you to dump contents to a file. It does this in an atomic manner: it writes a temporary file first and then moves it to the new file location when it's finished. This means that the user will always see either the complete old file or complete new file (but never a partially-written file):
阅读http://symfony.com/doc/current/components/filesystem.html
此代码应创建一个新的空文件。
$fs=new Filesystem();
$fs->dumpFile('/var/logs/file.txt', '');
关于php - Symfony 不通过 touch( ) 创建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43999953/
我是一名优秀的程序员,十分优秀!