zoukankan      html  css  js  c++  java
  • PHP文件函数代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    <?php
        
        //echo filetype("./1.jpg"); //判断文件类型  文件:file 
        //echo filetype("./code"); //目录 dir
        
        //echo is_dir("code"); //判断是不是目录
        //echo is_file("1.jpg"); //判断是不是文件
        
        //echo date("Y-m-d H:i:s",fileatime("1.jpg")); //获取上次的访问时间
        //echo date("Y-m-d H:i:s",filectime("1.jpg")); //文件的创建时间
        //echo date("Y-m-d H:i:s",filemtime("1.jpg")); //文件的修改时间
        //echo filesize("1.jpg")/1024; //文件的大小
        //echo file_exists("2.jpg"); //判断文件是否存在
        
        //echo filetype("/wamp");  //当前路径用./或不写;上以及用../; 
        
        /*正斜杠/代表根目录。如果是在php语言里写/则代表磁盘的根,如果是在网页的页面里面使用/则代表服务器的根*/
        
        //echo "<img src='/wenjiancaozuo/1.jpg' />";
        
        //echo $_SERVER['DOCUMENT_ROOT']; //找网站的根目录
        
        //echo basename("./code/db.inc.php",".php"); //从路径中返回文件名
        //echo dirname("./code/db.inc.php");//从路径中返回目录名
        //print_r(pathinfo("./code/db.inc.php"));//返回路径的所有信息,返回类型是数组
        //echo realpath("1.jpg"); //将相对路径转换为绝对路径
        
        /*目录操作*/
        //mkdir("./suiji"); //创建文件夹(目录)
        
        //rmdir("./suiji"); //删除目录,只能删除空的文件夹
        
         //rename("./name","./code/suiji"); //移动或重命名文件夹
         
         //print_r(glob("./code/*.php")); //获取该目录下所有文件,可以筛选
         
        /* //打开目录资源
         $dir = opendir("./code");
         //读文件,每读一条指针向下走一个,注意第一个是.代表当前目录,第二个是..代表上一级目录
         while($filename = readdir($dir))
         {
             echo $filename."<br>";
         }
         echo "***************************";
         rewinddir($dir);
          while($filename = readdir($dir))
         {
             echo $filename."<br>";
         }
         //关闭资源
         closedir($dir);*/
         
         /*文件操作*/
         //touch("./2.txt"); //创建文件
         //copy("./2.txt","./code/2.txt"); //复制文件
         //unlink("./code/2.txt"); //删除文件
         //echo file_get_contents("http://www.baidu.com"); //读取文件
         //file_put_contents("./2.txt","hello world"); //写入内容,会覆盖
         //readfile("http://www.baidu.com"); //读文件内容直接输出
        //$attr = file("./2.txt"); //读文件内容,然后返回每一行的数组
        
        $fp = fopen("./2.txt","r"); //打开文件资源
        
        //fwrite($fp,"bbbbbbbbbbb");//写入内容
        
        /*while(!feof($fp)) //当读取出错或者读到末尾返回true
        {
            echo fgetc($fp); //读取内容,一个字符一个字符读,读完指针下移
        }*/
        
        /*while(!feof($fp))
        {
            echo fgets($fp)."<br>"; //读取内容,每次读一行
        }*/
        
        //echo fread($fp,100); //读取内容,可以控制读取多少个字符
        
        fclose($fp);
        
        
    ?>
    </body>
    </html>
  • 相关阅读:
    六个月的实习
    cookbook学习第二弹
    cookbook学习第一弹
    maketrans translate
    Python strip函数用法小结
    【翻译】How To Tango With Django 1.5.4 第一章
    os相关方法总结
    python基础(一)
    bash快捷键
    Linux基本命令
  • 原文地址:https://www.cnblogs.com/fangchongyan/p/5217182.html
Copyright © 2011-2022 走看看