PHP,来自字符串的虚拟文件,无需在硬盘上写入

Age*_*nce 4 php

如果我有一个字符串(包含pdf文件)可以制作一个"虚拟"文件,以避免在硬盘上写入,以后用于需要现有文件的函数?

// theorical code

$file=stringToVirtualFile($string);

require($file);
Run Code Online (Sandbox Code Playgroud)

Mat*_*ndh 9

您可以使用特殊的php:// memory来获取引用内存数据而不是写入文件的数据的文件句柄.您也可以使用php:// temp来拥有一个文件支持的内存存储(如果文件默认超过2MB,则将文件写入磁盘).