#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    18
    Rep Power
    0
    This might be obvious, but I'm wondering how I can convert a variable containg html/php-code into actual code, i.e. something similiar to include()
    One way to do it would be to save the variable to file, and then include this, but there must be an easier way, right?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    14
    I may be wrong, but I think you should just be able to do that with echo:

    echo "$myvar";

    Chris
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    Chris, echo "$myvar"; won't work because it will simply echo the variable, not embed it in the actual script to be parsed by php.

    Metus, I don't know of a way to do what you're asking besides your own suggestion. *shrug*. Good luck.

    -weeder
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    18
    Rep Power
    0
    *hrmphh* Well, I thought this should be easy, but this is just silly... I actually did know that, I did... really, I did... *blush*
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    18
    Rep Power
    0
    Seems like we had a simultaneous post there... Well, echo did work fine, at least with html-tags...
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    14
    Weeder, not that I am disagreeing, but then why can you specifically call a function within an echo statement, like

    echo "phpinfo()";

    I am pretty sure I have done that before and it worked, have to play with it and see.

    Chris
  12. #7
  13. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    Guys,

    Check out eval() for parsing of php commands inside a variable.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    ah, eval(), of course. how silly of us all!

    ------------------

    - weeder
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    14
    Don't mind us, we are just a little slow

    Chris
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    18
    Rep Power
    0
    Well, I didn't know about eval() so I'm not stupid...or... well....

    Anyway, thanks for the help all. This was just what I was looking for. :-)

Similar Threads

  1. Replies: 4
    Last Post: February 13th, 2004, 03:31 PM
  2. A variable $_POST variable?
    By CLuver in forum PHP Development
    Replies: 0
    Last Post: February 11th, 2004, 12:55 AM
  3. variable variables problem
    By gbow in forum PHP Development
    Replies: 5
    Last Post: February 10th, 2004, 10:04 AM
  4. Ensuring a file's code doesn't cause error in another.
    By Jason Doucette in forum C Programming
    Replies: 0
    Last Post: February 6th, 2004, 12:51 PM
  5. How to read multiple line text file into a variable
    By gatewaycityca in forum Visual Basic Programming
    Replies: 4
    Last Post: January 29th, 2004, 12:26 PM

IMN logo majestic logo threadwatch logo seochat tools logo