尝试从大文件加载数据时出现错误503

时间:2020-04-17 22:31:51

标签: php json

我使我的代码可以轻松使用大数据,但仍然有无法处理的错误。 我该怎么做才能解决此错误?

<?php
$_SESSION['id'] = $_GET['id'];
ini_set('memory_limit', '-1');
$file = fopen("a.json", "r");
if ($file) {
    while (($line = fgets($file)) !== false) {
    }
    fclose($file);
} else {
} 
$searchfor = $_SESSION["id"];
header('Content-Type: text/plain');
$contents = file_get_contents("a.json");

$pattern = preg_quote($searchfor, '/');

$pattern = "/^.*$pattern.*\$/m";

if(preg_match_all($pattern, $contents, $matches)){
   echo implode($matches[0]);
}
else{
   echo "No matches found";
}

0 个答案:

没有答案