【问题标题】:fopen with a zip won´t work with php 7带有 zip 的 fopen 不适用于 php 7
【发布时间】:2018-01-15 10:24:12
【问题描述】:

我现在正在尝试修复我的 php 函数。由于某种原因,它不能再读取 .zip 文件了。它发生在我更改我的 linux 服务器之后。在我拥有 php 5.6 之前,我现在拥有 php PHP 版本 7.0.22-0ubuntu0.16.04.1。是否需要一些特殊的 php 库?

这是我的代码,但我不认为有什么问题,因为它以前工作过:

    /*
    Get donwloaded version
*/
$downloadVersion        =   "Unknown";

$fileData = function() {
    $file = fopen('zip://interface.zip#php/functions/functions.php', 'r');
    if (!$file)
    {
        die('Can not read zip file! Please be sure, that we have in this folder the interface.zip file!');
    };

    while (($line = fgets($file)) !== false)
    {
        yield $line;
    };
};

foreach ($fileData() as $line) {
    if(strpos($line, "define(\"INTERFACE_VERSION\"") !== false)
    {
        $lineparts          =   explode("\"", $line);
        $downloadVersion    =   $lineparts[3];
    };
};

顺便说一句,interface.zip 文件存在我还用 php file_exists 函数检查了它。路径和文件 functions.php 也退出。有人有想法吗?如果我尝试打开页面,它会显示:

无法读取 zip 文件!请确定,我们在此文件夹中有 interface.zip 文件!

【问题讨论】:

标签: php zip fopen


【解决方案1】:

我试过后发现

查看 stackoverflow.com/a/9817562/1894905 – 6339

无法加载整个 zip 存档。跑完之后

apt-get install php7.0-zip

在 shell 中安装了所需的库,并且可以正常工作。

感谢您的信息!

【讨论】:

    猜你喜欢
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 2018-02-20
    相关资源
    最近更新 更多