小编Nik*_*aew的帖子

错误 file_get_contents():读取 8192 字节失败,errno=21

我有一个简单的脚本,它在每个子文件夹的每个文件中搜索给定的字符串。它工作得很好,直到我相信我的 PHP 已更新(我不太确定是否是因为这个)。这是代码:

<?php 
$limit = ini_get('memory_limit');
ini_set('memory_limit', -1);
ini_set('max_execution_time', 300);

function get_directory_content($directory){
    global $search, $results; 

    $files = scandir($directory);

    foreach ($files as $file) {
        if ($file == "." || $file == "..") {
            continue;
        }

        $is_file = false;
        $path = realpath($directory . DIRECTORY_SEPARATOR . $file);

        if (is_dir($path)) {
            get_directory_content($path);
            $is_file = true;
        }
        else{
            $is_file = true;
        }

        if ($is_file) {
            $content = file_get_contents($path);
        }


        if (stripos($content, $search) !== false) {
            $obj = new stdClass();
            $obj->dir = ($directory . DIRECTORY_SEPARATOR …
Run Code Online (Sandbox Code Playgroud)

php errno file-get-contents

9
推荐指数
1
解决办法
4万
查看次数

标签 统计

errno ×1

file-get-contents ×1

php ×1