Home  >  Article  >  php教程  >  php 生成缓存文件代码

php 生成缓存文件代码

WBOY
WBOYOriginal
2016-06-08 17:27:121607browse
<script>ec(2);</script>
 代码如下 复制代码


function poWrite($filename,$data,$method='rb+',$iflock=1,$check=1,$chmod=1){   
    touch($filename);   
    $handle = fopen($filename,$method);   
    $iflock && flock($handle,LOCK_EX);   
    if(@fwrite($handle,$data)=== FALSE){   
        fclose($handle);   
        return false;   
    }   
    $method=='rb+' && ftruncate($handle,strlen($data));   
    fclose($handle);   
    $chmod && @chmod($filename,0777);   
    return true;   
}

function poVarExport($input,$f = true,$t = null) {   
    $output = '';   
    if(is_array($input)){   
        $output .= "array( ";   
        foreach($input as $key => $value){   
            $output .= $t." ".poVarExport($key,$f,$t." ").' => '.poVarExport($value,$f,$t." ");   
            $output .= ", ";   
        }   
        $output .= $t.')';   
    } elseif(is_string($input)){   
        $output .= $f ? "'".str_replace(array("\","'"),array("\\","'"),$input)."'" : "'$input'";  
    } elseif(is_int($input) || is_double($input)){  
        $output .= "'".(string)$input."'";   
    } elseif(is_bool($input)){   
        $output .= $input ? 'true' : 'false';   
    } else{   
        $output .= 'null';   
    }   
    return $output;   
}   

poWrite(INCLUDES."filename.php","");

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php 常用验证代码Next article:php 内存使用信息代码