Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
snippets:php:fgets [26-Jan-2021 19:40] Steve Joyntsnippets:php:fgets [02-Feb-2025 16:14] (current) – external edit 127.0.0.1
Line 1: Line 1:
 <file php> <file php>
  
-function fred() { +$filename = 'whatever'; 
-return true;+  
 +$fh = @fopen($filename, 'r'); 
 + 
 +if ( ! $fh ) { 
 +    throw new Exception("Failed to open ${filename}");
 } }
  
 +while ( ( $text = fgets($fh) ) !== false ) {
 +    echo $text;
 +}
  
 </file> </file>
  • snippets/php/fgets.1611690029.txt.gz
  • Last modified: 02-Feb-2025 16:12
  • (external edit)