zoukankan      html  css  js  c++  java
  • 007PHP文件处理—— 判断文件与操作文件fopen fread fclose is_executable is_readable is_writeable

    <?php
    /**
     * 判断文件与操作文件fopen  fread  fclose
     * is_executable is_readable is_writeable
     */
    //判断一个文件是不是一个可执行文件
    
    /*if (is_executable('bb.exe')!=FALSE){
        echo "这是一个文件他的大小是".filesize('bb.exe')/pow(1021,2).'MB';
    }*/
    
    /*is_string()  is_numeric()  is-array()  is_bool  is_file
     * */
    
    /*if (is_file(__FILE__)){
        echo __FILE__."是一个文件";
    }else{
        echo "不是一个文件";
    }*/
    
    //检测文件或文件夹是否存在时使用file_exists();
    /*if (file_exists('a')){
        echo "文件存在";
    }*/
    
    //判断文件是否可读:is_readable()
    /*if(is_readable('a.txt')){
        echo "文件可读";
    }else{
        echo "文件不可读";
    }*/
    
    //判断文件是否可写:is_writable()
    /*if(is_writable('a.txt')){
        echo "文件可写";
    }else{
        echo "文件不可写";
    }*/
    
    //文件操作
    /*$file=fopen('a.txt','r');
    echo fread($file,filesize('a.txt'));*/
    
    /*$file=fopen('a.txt','r');
    echo fread($file,2);
    echo fread($file,2);*/
    
    //文件读写模式:r+
    $file=fopen('a.txt','r+');
    fwrite($file,'123456789');//往文件李曼写入内容
    fclose($file);
    

      

  • 相关阅读:
    三大范式
    html 横线的代码
    CSS下拉 菜单3.27第一次
    JS页面三种打开方式及对话框
    函数整理
    3.22整理作业
    for循环,if 练习
    php测试题
    设计模式
    面向对象的三大特性
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/8269526.html
Copyright © 2011-2022 走看看