Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member [Li] Brad's Avatar
    Join Date
    Oct 2003
    Location
    Saskatoon, Canada
    Posts
    578
    Member #
    3689
    Hello all,

    I don't know if my brain has been used too much today or what, but can anyone tell me the plain and simple way to write PHP to a file with PHP?

    This is what I have:
    PHP Code:
    fwrite($f, "<?php $logins[$result][\"$id\"]=\"$userIDentered\";"); ?>
    You can probably already see that this won't work. I want it so that when I open this file, the PHP code gets executed. But writing like this, it looks for the $logins variable which does not exist for this file.

    Any assistance is appreciated.
    [Li] Brad

    edit: to make it clear, $result is a variable I want to include in the writing of this file, so is $userIDentered and $id.
    "Art strives for form, and hopes for beauty." - George Bellows

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Escape the $ with a \. For example:
    PHP Code:
    $junk "test";
    echo 
    "$junk...\$junk"
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    try the escape (\) prior to the $ so it writes the character instead of processing it, like so:
    Code:
    fwrite($f, "\<?php \$logins[\$result][\"\$id\"]=\"\$userIDentered\"; ?\>");

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Haha, you beat me by a fraction of a second, filb


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:32 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com