I'm trying to create a file using PHP but the problem is that the needed file has no name but only an extension. How can I do it? The present code just doesn't make the file but it also doesn't give me an error.
我正在尝试使用PHP创建一个文件,但问题是所需的文件没有名称,只有一个扩展名。我该怎么做?目前的代码只是不生成文件,但它也没有给我一个错误。
fopen( '.extension', 'w' )or die( 'ERROR MESSAGE' );
1 个解决方案
#1
1
Files with only an extension and no name are treated as hidden in unix. To list them, you might call ls -la
inside the terminal.
只有扩展名且没有名称的文件在unix中被视为隐藏。要列出它们,您可以在终端内调用ls -la。
So the code you posted should just work fine. Note: you should always close the file opend with fopen
!
所以你发布的代码应该可以正常工作。注意:你应该总是用fopen关闭文件opend!
$f = fopen( '.extension', 'w' );
if ($f) {
fclose($f);
}
#1
1
Files with only an extension and no name are treated as hidden in unix. To list them, you might call ls -la
inside the terminal.
只有扩展名且没有名称的文件在unix中被视为隐藏。要列出它们,您可以在终端内调用ls -la。
So the code you posted should just work fine. Note: you should always close the file opend with fopen
!
所以你发布的代码应该可以正常工作。注意:你应该总是用fopen关闭文件opend!
$f = fopen( '.extension', 'w' );
if ($f) {
fclose($f);
}