Jump to content


Photo

How to evaluate this code?


  • Please log in to reply
6 replies to this topic

#1 EXECUTRON

EXECUTRON
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 May 2006 - 02:59 AM

I've got a block of code in a string that was grabbed through file_get_contents (it has to be done this way).

I tried putting <<<EOF around it and echoing it but it doesn't seem to work.

Anyone have any ideas? I don't want to use eval.

<html>

  <head>
    
    <title>Sample</title>
    
  </head>
  
  <body>
    
    global header
    
    global navigation
    
    <form name="{$Skin['page_template']}" action="{$Skin['form_action']}">



<div id="text_field_container">

    

    <div id="text_field_input">

        

        <input type="text" name="{$DB['element_name']}" />

        

    </div>

    

    <div id="text_field_info">

        

        {$DB['element_info']}

        

    </div>

    

</div>



<div id="password_field_container">

    

    <div id="password_field_input">

        

        <input type="password" name="{$DB['element_name']}" />

        

    </div>

    

    <div id="password_field_info">

        

        {$DB['element_info']}

        

    </div>

    

</div>



<div id="submit_button_container">
    
    <div id="submit_button">
        
        <input type="submit" name="{$LANG['submit_button']}" value="Submit" />
        
    </div>
    
</div>



</form>
    
    global footer

{$System['copyright]'}
    
  </body>
  
</html>


#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 03:44 AM

From what I understand of your post, the answer lies in using eval(). See:

[a href=\"http://us2.php.net/manual/en/function.eval.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.eval.php[/a]



#3 EXECUTRON

EXECUTRON
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 May 2006 - 03:47 AM

[!--quoteo(post=373410:date=May 12 2006, 11:44 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 12 2006, 11:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
From what I understand of your post, the answer lies in using eval(). See:

[a href=\"http://us2.php.net/manual/en/function.eval.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.eval.php[/a]
[/quote]
Yeah, I fear this is the only way... which is really slow.

#4 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 03:50 AM

Well, since it's already in a file, why not just include/require it. But you have to use the php tags and echo, even with eval().

#5 EXECUTRON

EXECUTRON
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 May 2006 - 05:30 AM

[!--quoteo(post=373412:date=May 12 2006, 11:50 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 12 2006, 11:50 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Well, since it's already in a file, why not just include/require it. But you have to use the php tags and echo, even with eval().
[/quote]
I have to use file_get_contents because I'm doing a lot of regex on the string before it's in the above state.

#6 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 05:34 AM

Well, you then can write the file out after the regex and include/require it or use the eval().

Other choices is to use a template system such as Smarty.

Good luck.


#7 EXECUTRON

EXECUTRON
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 May 2006 - 05:43 AM

[!--quoteo(post=373425:date=May 13 2006, 01:34 AM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 13 2006, 01:34 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Well, you then can write the file out after the regex and include/require it or use the eval().

Other choices is to use a template system such as Smarty.

Good luck.
[/quote]
Yeah, seems to be the only options.

I think I'll use eval.

Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users