For example:
$contents = file_get_contents(image.png);
Is it possible to create a SplFileObject object from $contents?
Thanks!
php has some special stream wrappers that let you re purpose the various file system functions
$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);
You don't need to use SplFileObject to use those wrappers though; you could use fopen and fwrite instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With