首頁 > php教程 > PHP源码 > 主體

php 生成缓存文件代码

WBOY
發布: 2016-06-08 17:27:12
原創
1611 人瀏覽過
<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","");

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!