lopes_andre Posted January 10, 2009 Share Posted January 10, 2009 Hi, I need to put some php code inside variables. It is possible? <?php /** * @author duioi * @copyright 2009 */ $part1 = 'echo "11111";'; $part2 = 'echo "22222";'; ?> <table width="653" border="0" align="center"> <tr> <td width="124"><?php $part1 ?></td> <td width="431"><?php $part2 ?></td> </tr> </table> This code is not working. But I don't know why. How to get this working? Best Regards. André. Link to comment https://forums.phpfreaks.com/topic/140309-how-to-get-this-code-working/ Share on other sites More sharing options...
corbin Posted January 10, 2009 Share Posted January 10, 2009 You could use eval to do that, but you're going about it the wrong way. <?php $part1 = '11111'; $part2 = '22222'; ?> <table width="653" border="0" align="center"> <tr> <td width="124"><?php echo $part1 ?></td> <td width="431"><?php echo $part2 ?></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/140309-how-to-get-this-code-working/#findComment-734194 Share on other sites More sharing options...
bubbasheeko Posted January 10, 2009 Share Posted January 10, 2009 Corbin!! Beating me to it... lol Eval() would work, but after testing - I found that it didn't like an echo statement in it. It would still print the word 'echo'. Link to comment https://forums.phpfreaks.com/topic/140309-how-to-get-this-code-working/#findComment-734198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.