fclose
-
To close a file in PHP, you pass its stream resource to
fclose.PHP
$f = fopen('/path/to/foobar', 'w'); fwrite($f, 'chars'); fclose($f);
Similarly, if you use Ruby’s
File.openmethod to return a file instance, you need to call theclosemethod on that instance.Ruby
f = File.open('/path/to/foobar', 'w') f.write 'chars' f.close
Alternatively, you can have Ruby automatically close files that you open by passing a block to the
File.openmethod:Ruby
File.open('/path/to/foobar', 'w') do |f| f.write 'chars' end
Using a block in this way is considered a best practice in Rails applications. For more on this, please see fopen.
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

