The Little Guy Posted January 11, 2013 Share Posted January 11, 2013 I am making a template library I am extracting data from a template, like this one for example: <!DOCTYPE html> <html> <head> <title>If/Else</title> <body> $if($get.id == 0): <span style="color: green">GET is 0</span> $elseif($get.id == 1): <span style="color: yellow">GET is 1</span> $elseif($get.id == 2): <span style="color: yellow">GET is 2</span> $else: <span style="color: red">GET is not Set!</span> $endif; </body> </html> What I have now, is I extract all the required data that I need between ( and ) for each if, elseif using some regexp. in my php have have the following after the data is extracted: <?php // Extrat the data and make these variables: $ifStmt = "$get.id == 0"; $ifElseStmts = array( [0] => "$get.id == 1", [1] => "$get.id == 2" ); Now the question that I have is that need to evaluate each one until I find one that gives true as a result. I was thinking of doing eval, but that isn't really secure, so any suggestions on what I should do to evaluate the if statements? Link to comment https://forums.phpfreaks.com/topic/273024-execute-ifelse-statements-generated-from-a-template/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.