Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post

    Saving with variables

    Ok i'm using php to save a webpage to the webserver. The saved file's name is supposed to be equal to the variable $uic I can't get it to display the value of $uic

    heres the code:
    PHP Code:
    $return file_put_contents('../../../archives/docs/account_details/$uic.txt'$content); 
    that saves the file called $uic.txt instead of printing: 7706869110330709208613965.txt

    does anybody know how i can fix this?

  • #2
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    when i make the code like this:
    PHP Code:
    $return file_put_contents('../../../archives/docs/account_details/'$uic.txt$content); 
    i get this error message:

    Code:
    Parse error: syntax error, unexpected T_VARIABLE

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    You might want to buy a PHP book.

    You have to concatenate strings with variables using the concatenation operator.

    PHP Code:
    $return file_put_contents('../../../archives/docs/account_details/' $uic.txt$content); 
    Notice the period?

    PHP Code:
    $return file_put_contents('../../../archives/docs/account_details/$uic.txt'$content); 
    PHP does not parse single quoted strings for variables.

    PHP Code:
    $return file_put_contents("../../../archives/docs/account_details/$uic.txt"$content); 

  • Users who have thanked aedrin for this post:

    Doom87 (11-09-2007)


  •  

    Posting Permissions

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