1
有没有一种方法可以从phar中访问文件,而无需首先将phar保存到磁盘?在以下代码中,$fileContentsString
是从网络加载的phar文件的内容。我如何获取该字符串并从中读取文件,而无需首先将字符串作为文件保存到磁盘?我试过将字符串写入php://temp
,然后使用Phar::loadPhar
来读取它,但是失败了。从内存中读取phar文件?
$tmpFilePath = TMP_PATH . '/' . $filename;
// Save the file to TMP_PATH
$fp = fopen($tmpFilePath, 'w');
fwrite($fp, $fileContentsString);
fclose($fp);
$contents = file_get_contents('phar://' . $tmpFilePath . '/json.txt');