例如:
$contents = file_get_contents(image.png);
是否可以从$ contents?
创建SplFileObject对象谢谢!
答案 0 :(得分:10)
php有一些special stream wrappers可以让您重新使用各种文件系统函数
$contents = 'i am a string';
$file = 'php://memory'; //full memory buffering mode
//$file = 'php://temp/maxmemory:1048576'; //partial memory buffering mode. Tries to use memory, but over 1MB will automatically page the excess to a file.
$o = new SplFileObject($file, 'w+');
$o->fwrite($contents);
您不需要使用SplFileObject来使用这些包装器;您可以改用fopen和fwrite。