Why does reading from a php://memory wrapper I've just written to fail? -


i'm trying read php://memory wrapper using fread() fread() returns false. code simplified:

$file_handle = fopen('php://memory', 'w+'); // have tried php:temp also. fwrite($file_handle, 'contents'); $file = fread($file_handle, filesize($file_handle)); // have tried 99999 filesize. 

$file false after fread().

what's going on?

thanks in advance!

you'll need rewind($file_handle) after writing before can read you've written, because writing moves file pointer end of file


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -