eval question

Discussion in 'PHP' started by redhits, Feb 28, 2008.

  1. #1
    Hello , i am having a question about the eval function


    I always need to read some data from text file, and then call the eval function

    my problem is that if the text have sign like " , or ; , then i get errors and it's not evaling the code...

    My questions is , how i can make eval only to evalutate $variables


    like to change variables names, not to eval the whole text as php code?
     
    redhits, Feb 28, 2008 IP
  2. RoscoeT

    RoscoeT Peon

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you post an example ? use code tags if DP allows it.
     
    RoscoeT, Feb 28, 2008 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Perhaps you want to use sprintf() instead.
     
    nico_swd, Feb 29, 2008 IP
  4. redhits

    redhits Notable Member

    Messages:
    3,023
    Likes Received:
    277
    Best Answers:
    0
    Trophy Points:
    255
    #4
    I solved this problem str_replace

    like
    $string=str_replace('$name',$name);
    :)))

    you can do an explode , to count all words starting with an $ if you want
     
    redhits, Mar 1, 2008 IP