Running PHP code from a string?

Discussion in 'PHP' started by kuser, Jun 28, 2012.

  1. #1
    I am would like to run the PHP code i am getting from a "string". how i can do this?
     
    kuser, Jun 28, 2012 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    ssmm987, Jun 28, 2012 IP
  3. Custom IDX/MLS

    Custom IDX/MLS Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    eval() with base64_decode() can do some nifty things with strings
     
    Custom IDX/MLS, Jun 28, 2012 IP
  4. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #4
    Dangerous. You should rethink what you are trying to do. You probably are taking the wrong approach.
     
    NetStar, Jun 28, 2012 IP
  5. DevSwift

    DevSwift Peon

    Messages:
    103
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Agreed, especially when using eval on user-provided strings.
     
    DevSwift, Jun 28, 2012 IP
  6. liquidfire

    liquidfire Greenhorn Affiliate Manager

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #6
    Using eval() in any system is generally not a good idea..
     
    liquidfire, Jun 28, 2012 IP
  7. 137th Gebirg

    137th Gebirg Active Member

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #7
    You may want to try Exec() if you're trying to execute a string as a command-line action. Another thing you have to worry about is that if you're trying to start programs on the Windows desktop with PHP using the "Eval" or "Exec" commands and you're running Apache, you will need to go into the Services application, double-click on the Apache service, click on the "Log On" tab, click the "Local System Account" radio button and check the "Allow service to interact with desktop" checkbox. If you don't, Windows-based apps will only run in the background but NOT ever appear on the desktop. Ran into that problem a few years back and it took me weeks to figure it out. Good luck!
     
    137th Gebirg, Jun 29, 2012 IP