PHP文件编程

it2025-12-30  4

PHP文件编程

<?php // 往文件中写入内容 // 如果文件不存在 则会自动创建文件 file_put_contents('01.txt', '我是写入的内容'); // 打开文件 第二个参数是模式 w是写入模式 r是只读模式 a是尾部追加 $fp = fopen('01.txt', 'w'); fputs($fp, '我是即将写入的内容'); fclose($fp); // 读取文件中的内容 echo file_get_contents("01.txt"); // 判断文件是否存在 echo file_exists("01.txt"); // 判断是不是文件 echo is_file('01.txt'); // 删除文件 echo unlink(); // 判断是不是目录 echo is_dir("aa"); //打开目录 echo opendir("aa"); // 读取目录中的内容 echo readdir("aa"); //删除目录 rmdir("aa"); // 创建目录 true表示递归创建 mkdir('bb/aa', 0777, true);
最新回复(0)