Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: $ Sign Decode

  1. #1
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default $ Sign Decode

    Essentially I'm making a PHP script using php, but I can't define variables.

    If I try:
    Code:
    $phpcode .= "html_entity_decode("&#36")myvar = \"test\"";
    It won't work... I think I've tried just about everything.
    Any ideas?
    - Mike

  2. #2
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Stupid question:
    Code:
    $phpcode .= "\$myvar = \"test\"";
    how about this?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'd think there are some problems with using a function within quotes like that.

    Usually, I'd go with:
    func(...)."something"
    etc.

    The dollar sign is by default slashed, I believe, within a thread, to prevent problems. There is likely a way around this.

    Are you later using the eval() function?

    If you can tell us the purpose, we can figure it out more. From what you posted, I truly see no point in it... just type the literal line. But there must be some reason beyond that for using it.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Haha... you know what else is stupid ItsMeOnly? That your stupid solution doesn't work.
    - Mike

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    In my opinoin no real question is stupid (as long as it is an actual question and not a spammer trying to make posts). I'm not sure what it is you are trying to accomplish here. Maybe some more insite would help.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    I actually have the problem solved now. I stored the "$" sign in a variable and called it later. Using it outside the string keeps it from being read as a variable which already exists. If said variable doesn't exist it will appear blank, and that was the error I was getting.
    - Mike

  7. #7
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Well, because PHP automatically parses anything in double quotes(" & "), you need to use single quotes.
    PHP Code:
    $some_value 'some random string';
    $php_code '$some_var = "'.$some_value.'"'

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Point taken, thanks Brady. This is what I did though:
    Code:
    $dsign = "$";
    $phpcode = $dsign."query = \"mysql query...\"";
    - Mike

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That works, or the single quote solution is easy.
    Also, ItsMeOnly's phrasing wasn't great, but it wasn't an insult to you. He meant HIS question was stupid (asking if it would work), not that yours was.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I must say that, as is usual with eval(), there's probably a better way to accomplish whatever it is you're trying to do.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •