例如:
$contents = file_get_contents(image.png);
Run Code Online (Sandbox Code Playgroud)
是否可以从$ contents创建SplFileObject对象?
谢谢!
goa*_*oat 11
php有一些特殊的流包装器,可以让你重新使用各种文件系统功能
$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);
Run Code Online (Sandbox Code Playgroud)
您不需要使用SplFileObject来使用这些包装器; 你可以使用fopen和fwrite代替.
| 归档时间: |
|
| 查看次数: |
3474 次 |
| 最近记录: |