You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


PHP provides useful functions can read file directly instead of open → read → close: readfile(), file_get_contents() - personally I prefer to use file_get_contents(), because it does not display anything after reading the content.

Option 1) readfile( $filename)

$src = "src/new.json";
$tmp = readfile( $src);
echo $tmp;


Option 2) file_get_contents( $filename)

Unlike readfile(), it does not display anything on the screen.

$src = "src/new.json";
$tmp = file_get_contents( $src);
echo $tmp;
  • No labels