# Re: file\_put\_contents analog?

**URL:** <https://www.ruby-forum.com/t/re-file-put-contents-analog/72064>\
**Category:** Ruby\
**Created:** [October 13, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/re-file-put-contents-analog/72064 "2006-10-13T22:35:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 13, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/re-file-put-contents-analog/72064/1 "2006-10-13T22:35:42Z")

</div>

From: Joe R. MUDCRAP-CE

> PHP has a function file\_put\_contents(file, stuff) – is there any  
> similar single command in Ruby?

def file\_put\_contents( name, \*contents )  
File.open( name, “w+” { |file|  
contents.each{ |item|  
file \<\< item  
}  
}  
end
