file操作

来源:互联网 发布:plc是单片机吗 编辑:程序博客网 时间:2024/05/16 06:28
<?php

$root_dir = dirname(__FILE__);

/**
 * 文件操作类
 * Class FileOperation
 */
class FileOperation{

    /**
     * 实例
     */
    static $handle = null;

    /**
     * 初始化
     */
    function __construct($fileName = 'reptile_quanguo_1_error') {
        chmod(dirname(__FILE__), 0777);
        $errorFile = $fileName.date("Y-m-d").'.txt';
        self::$handle = fopen($errorFile, 'a');
    }

    /**
     *  写入文件
     **/
    function writeToTxt($data) {
        // 写入的内容
        fwrite(self::$handle, $data);
    }//function end

    /**
     *  写入文件
     **/
    function closeTxt() {
        // 关闭b.php文件
        fclose(self::$handle);
        // 销毁文件资源句柄变量
        //unset($handle);
    }



}//class end
0 0
原创粉丝点击