# Concatenate and write to a file in PHP questions

**URL:** <https://forum.kirupa.com/t/concatenate-and-write-to-a-file-in-php-questions/120437>\
**Category:** Uncategorized\
**Created:** [August 24, 2004, 9:31am UTC](https://forum.kirupa.com/t/concatenate-and-write-to-a-file-in-php-questions/120437 "2004-08-24T09:31:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aufkes](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@aufkes](https://forum.kirupa.com/u/aufkes)\
**Post date:** [August 24, 2004, 9:31am UTC](https://forum.kirupa.com/t/concatenate-and-write-to-a-file-in-php-questions/120437/1 "2004-08-24T09:31:31Z")

</div>

Hello to all,  
I have two simple questions, but I’m new in PHP and don’t know exactly how to do it.  
I’m converting a XML into an HTML file using PHP. Now the HTML file is show on the screen after runing the PHP script that parse the XML file. Instead of showing the HTML file on the screen I want to write it on a local file for later use. This file must be created on the fly, so it doesn’t exit localy. How can I do that? Should I use the fopen function or there is other better?

On the other hand, the HMTL file should have a name with the date and time, somethig like this:

namefile\_20040824\_111520.html  
namefile\_YYYYMMDD\_HHMMSS.html  
YYYY --\> Year  
MM --\>moth  
DD --\> day  
HH --\> Hour  
MM --\> minutes  
SS --\> seconds

I know that in other languages there is a sentence to concatenate strings in order to name a file. Is there something similar in PHP?

Thanks to all.

---

<div class="post-metadata">

**Author:** ![ol4pr0](https://avatars.discourse-cdn.com/v4/letter/o/5fc32e/32.png) [@ol4pr0](https://forum.kirupa.com/u/ol4pr0)\
**Post date:** [August 24, 2004, 8:01pm UTC](https://forum.kirupa.com/t/concatenate-and-write-to-a-file-in-php-questions/120437/2 "2004-08-24T20:01:12Z")

</div>

you mean just giving it the extension .html ? no need for anything special doing that.

---

<div class="post-metadata">

**Author:** ![cmd](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@cmd](https://forum.kirupa.com/u/cmd)\
**Post date:** [August 24, 2004, 10:27pm UTC](https://forum.kirupa.com/t/concatenate-and-write-to-a-file-in-php-questions/120437/3 "2004-08-24T22:27:32Z")

</div>

> [@ol4pr0](#):
>
> you mean just giving it the extension .html ? no need for anything special doing that.

i think he means he wants to save the parsed xml file to another file. u gotta use fopen, fwrite then to write to the file for later use.

chris
