您好,欢迎访问一九零五行业门户网

php 生成缓存文件代码

代码如下 复制代码
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,);
其它类似信息

推荐信息