To create a file in PHP, you can use the fopen()
function to open a file handle and then use the fwrite()
function to write content into the file. Here's an example code snippet that demonstrates how to create a file in PHP:
main.php230 chars12 lines
In this example, the fopen()
function is used with the w
mode parameter to open a file handle for writing. The file path and name are specified in the $file
variable. The fwrite()
function is then used to write the string "Hello, World!" to the file. Finally, the fclose()
function is used to close the file handle.
gistlibby LogSnag