Writing files to temporary locations
<p>I have a requirement to write a file as part of a PHP script (XML contents with a custom file extension), then once the file has been saved to then attach that to an email I'll be sending using PHP Mailer.</p>

<p>The emailing part is fine but I've never had to write a file with PHP before.  The file is only required for the duration of the script and doesn't need to be kept permanently.</p>

<p>How can I write a file to a temporary location?</p>

<p>Do I need to clean up the temporary location when done with the file?  If so, how?</p>
