SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    writing variables such as $variable with fwrite()

    Hey guys!

    I'm just trying to create a file using the fwrite() function. My script looks something like this:

    PHP Code:
    fwrite($do, "<?
        
    include '_side.php';
        
    ?>
        <h1>About BIS</h1>
        <div class='black'>
        <?=  
        $about ?>
        <div style='padding-left: 450px; padding-top: 20px;'>
        <a href='#top'>back to top</a>
        </div>
        </div>");
    the $about variable is causing problems, because I want it to say $about in the file, but PHP interprets it as "" because doesnt have a value... any ideas how i could work around that so that in the php file it creates it will say

    <?
    include '_side.php';
    ?>
    <h1>About BIS</h1>
    <div class='black'>
    <?=
    $about ?>
    <div style='padding-left: 450px; padding-top: 20px;'>
    <a href='#top'>back to top</a>
    </div>
    </div>

    thanks!

    Fabian

  2. #2
    SitePoint Evangelist Rodney H.'s Avatar
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try one of the following:

    1) Escape the $ (dollar sign) in the string with a backslash: \$about

    2) Put the string in SINGLE quotes


    ... so PHP won't interpret the dollar sign as the beginning of a variable name that it should interpret

    Hope that helps...
    Last edited by Rodney H.; Sep 17, 2006 at 10:49.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oooohhh yeah the backslash thing worked!

    thanks a lot!

    fabian


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •