KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
If I have a short function that opens a file and reads a line, do I need to close the file? Or will PHP do this automatically when execution exits the function and $fh is garbage collected? function first_line($file) { $fh = fopen($file); $first_line = fgets($fh); fclose($fh); return $first_line; } could then be simplified to function first_line($file) { return fgets(fopen($file)); } This is of course theoretical right now, as this code doesn't have any error handling .
Tags (comma-separated)
Save Edits
Cancel