Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check when file_get_contents is finished

Is there anyway I can check when file_get_contents has finished loading the file, so I can load another file, will it automatically finish loading the one file before going onto the next one?

like image 560
Liam Bailey Avatar asked Nov 29 '22 04:11

Liam Bailey


2 Answers

Loading a file with file_get_contents() will block operation of your script until PHP is finished reading it in completely. It must, because you couldn't assign the $content = otherwise.

like image 139
mario Avatar answered Dec 10 '22 08:12

mario


PHP is single threaded - all functions happen one after the other. There is a php_threading PECL extension if you did want to try loading files asynchronously, but I haven't tried it myself so I can't say if it would work or not.

like image 39
Rob Agar Avatar answered Dec 10 '22 08:12

Rob Agar