Created
December 1, 2021 13:48
-
-
Save SerafimArts/8e7ae7b635bd6a5a6f15e868bd67544d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function file_get_contents(string $pathname): string | |
{ | |
$result = ''; | |
$fp = fopen($pathname, 'rb'); | |
while (!feof($fp)) { | |
$chunk = 1024; | |
Fiber::getCurrent() && ($chunk = (Fiber::suspend() ?: 1024)); | |
$result .= fread($fp, $chunk); | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment