SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    execute a string

    let's say i have a string with:

    $var="echo what?;";

    and i want to execute that string, how do i do that?

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo what?; isn't valid PHP, but apart from that, you're looking for eval. Be advised though, that using eval is generally considered bad practise, and can be a source of security problems.

  3. #3
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $var='echo "what?";';
    eval(
    $var); 
    read more but, there are security concerns.
    my mobile portal
    ghiris.ro

  4. #4
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    kyberfabrikken

    You quick
    my mobile portal
    ghiris.ro

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks both, i'll checkout eval!


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
  •