本文整理汇总了PHP中Encoding::compatible_gzinflate方法的典型用法代码示例。如果您正苦于以下问题:PHP Encoding::compatible_gzinflate方法的具体用法?PHP Encoding::compatible_gzinflate怎么用?PHP Encoding::compatible_gzinflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::compatible_gzinflate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decompress
/**
* Decompression of deflated string.
*
* Will attempt to decompress using the RFC 1950 standard, and if that fails
* then the RFC 1951 standard deflate will be attempted. Finally, the RFC
* 1952 standard gzip decode will be attempted. If all fail, then the
* original compressed string will be returned.
*
* @since 2.8
*
* @param string $compressed String to decompress.
* @param int $length The optional length of the compressed data.
* @return string|bool False on failure.
*/
public static function decompress($compressed, $length = null)
{
if (empty($compressed)) {
return $compressed;
}
if (false !== ($decompressed = @gzinflate($compressed))) {
return $decompressed;
}
if (false !== ($decompressed = Encoding::compatible_gzinflate($compressed))) {
return $decompressed;
}
if (false !== ($decompressed = @gzuncompress($compressed))) {
return $decompressed;
}
if (function_exists('gzdecode')) {
$decompressed = @gzdecode($compressed);
if (false !== $decompressed) {
return $decompressed;
}
}
return $compressed;
}