# PHP vars to text file

**URL:** https://forum.kirupa.com/t/php-vars-to-text-file/221303
**Category:** programming
**Created:** [April 3, 2007, 8:49am UTC](https://forum.kirupa.com/t/php-vars-to-text-file/221303 "2007-04-03T08:49:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ajcates](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ajcates/32/2435_2.png) [@ajcates](https://forum.kirupa.com/u/ajcates)
#### Post date: [April 3, 2007, 8:49am UTC](https://forum.kirupa.com/t/php-vars-to-text-file/221303/1 "2007-04-03T08:49:10Z")

</div>

ok lets say i have the flowing code

```php

$fileName = "bob.txt";
$fileContents = "this is what i want inside the file";

```

i would like to take $fileContents and write it to a text file called $fileName, could some one please give me an example of how this would be done, i am very very new to php. thank you very much! also i don’t want to edit a file, i want to create a new one based on the fileName, all the tuts show me how to edit a file but not make a new one
