SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast emplynx's Avatar
    Join Date
    Apr 2003
    Location
    West Virginia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Variable in a text string.

    I realize this is a stupid question, but I honistly can't find the answer. I'm working on some PHP script for the LotR Action Figure Storybook and can't find out how to have PHP recognize a variable in a string of text.
    Specifically, I want "if (file_exists("images/$bookafs_$page$one.jpg")) {"
    to see $book as the variable, not $bookafs as the variable. How do I do that?

  2. #2
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (file_exists('images/' $book 'afs_' $page '' .$one '.jpg' )) { 

  3. #3
    SitePoint Enthusiast emplynx's Avatar
    Join Date
    Apr 2003
    Location
    West Virginia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much. I actually remeber that notation from Kevin's book, but was confused on how it worked.

  4. #4
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem. there are no stupid questions friend. If there were then I'm sure Iv'e asked them all allready.

  5. #5
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alternately
    PHP Code:
    if (file_exists("images/{$book}afs_{$page}{$one}.jpg" )) { 
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  6. #6
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that never looks right to me so I don't do it that way. Just a matter of preference I guess.

  7. #7
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree in general, but there are special cases where I find the brace notation preferable.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  8. #8
    SitePoint Enthusiast emplynx's Avatar
    Join Date
    Apr 2003
    Location
    West Virginia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, I think in this case, the braces would have been easier to work with, but I got it working!

  9. #9
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anode
    Alternately
    PHP Code:
    if (file_exists("images/{$book}afs_$page$one.jpg" )) { 
    would have worked too.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


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
  •