初识php3

来源:互联网 发布:互联网企业 知乎 编辑:程序博客网 时间:2024/06/15 21:15
<?php/** * Created by PhpStorm. * User: dllo * Date: 16/8/9 * Time: 下午2:24 */header("Content-type:text/html;charset=utf-8");// 打开文件// r 只读,只能读取文件// w,可以写入文件内容,会覆盖原来的内容,如果文件不存在会创建// a 在原来内容的基础上追加内容$file = fopen("1.txt","a");// 获取文件内容// 1. 文件// 2. 要获取的大小// filesize()获取文件大小//echo fread($file,filesize("1.txt"));// 按行读取内容//echo fgets($file);//echo fgets($file);//echo fgets($file);//while($content = fgets($file)){//    echo "<br>";//    echo $content;//}// 读取整个文件内容//echo file_get_contents("1.txt");//echo file_get_contents("http://www.baidu.com");// 把文件内容按行读取为数组//print_r(file("1.txt"));// 写入文件内容//echo fwrite($file,"你好a ");// 写入文件内容//echo file_put_contents("1.txt","kjhfuwe");// 复制//echo copy("1.txt","2.txt");// 重命名//rename("1.txt","1.html");echo unlink("2.txt");// 关闭文件//fclose($file);
0 0
原创粉丝点击