# Using "fwrite" in php

**URL:** <https://forum.kirupa.com/t/using-fwrite-in-php/244780>\
**Category:** Uncategorized\
**Created:** [November 21, 2007, 5:30pm UTC](https://forum.kirupa.com/t/using-fwrite-in-php/244780 "2007-11-21T17:30:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iNeed\_Help](https://avatars.discourse-cdn.com/v4/letter/i/49beb7/32.png) [@iNeed\_Help](https://forum.kirupa.com/u/iNeed_Help)\
**Post date:** [November 21, 2007, 5:30pm UTC](https://forum.kirupa.com/t/using-fwrite-in-php/244780/1 "2007-11-21T17:30:02Z")

</div>

I hope u lot aint sick of me…  
Basically, the code below creates a few variables. The 1st variable is called $index\_str, inside this variable is a string of text and another variable inside it called “$var1”. The 2nd variable is called $pagetemp and it has all the contents from inside a file called pagetemp.php. The content of these two variables($index\_str & $pagetemp) are then written into a new file called newPage.php.

Here’s the code:

```php

<?php
 $index_str = "This is my string" . "
";
 $index_str .= "$var1 = \"is the variable I want to put into the new page\" . "
";
 $pagetemp = file_get_contents("pagetemp.php");
 $client_index = fopen("newPage.php", 'w+');
 fwrite($client_index, $index_str . "
" . $pagetemp);
?>

```

Problem is… Once the new page is created, the variable $var1 is not shown… Can anyone help? I find it hard to word what I mean when I talk about all this coding stuff, so just ask if u want me to try and elaborate more.

Thanx
