创建一个php文件

Mat*_*nes 1 php

有没有可以在指定目录中创建文件的脚本?喜欢

<?php

createfile("hi.txt","/home/public_html/files");

?>

mez*_*eze 5

您可以使用file_put_contents

<?php

file_put_contents("/home/public_html/files/hi.txt", "content");

?>
Run Code Online (Sandbox Code Playgroud)

或者,如果您不需要内容并且只想确保文件已创建,请触摸

<?php

touch("/home/public_html/files/hi.txt");

?>
Run Code Online (Sandbox Code Playgroud)