Skip to content

Instantly share code, notes, and snippets.

@SerafimArts
Created December 1, 2021 13:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SerafimArts/8e7ae7b635bd6a5a6f15e868bd67544d to your computer and use it in GitHub Desktop.
Save SerafimArts/8e7ae7b635bd6a5a6f15e868bd67544d to your computer and use it in GitHub Desktop.
<?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