例如:
$contents = file_get_contents(image.png);
是否可以从 $contents 创建 SplFileObject 对象?
Thanks!
php 有一些特殊的流包装器 http://www.php.net/manual/en/wrappers.php.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);
你不需要使用Spl文件对象 http://php.net/manual/en/class.splfileobject.php不过要使用这些包装器;你可以用fopen http://php.net/manual/en/function.fopen.php and fwrite http://php.net/manual/en/function.fwrite.php反而。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)