About fwrite in php
<p>I am creating file in php by using <code>fwrite</code>. I need to attach the database to my <code>index.php</code> My doubt is can I print the below line on <code>fwrite</code>? I have tried it but it shows error. Is there any way for this?</p>

<pre><code>$fd =fopen("database.php","w");

fwrite($fd, "$dbhost='localhost';
    $dbuser='$user';
    $dbpass='$pass';
    $dbname='$email';
    $dbh = new PDO('mysql:host=localhost;dbname=$email', $dbuser, $dbpass);");

fclose($fd);
</code></pre>