mysticssjgoku4 Posted May 14, 2006 Share Posted May 14, 2006 Hello there,I'm trying to execute a function such as "include('file.php');" by echoing it through a variable.Set Before Loading Page:[code]$skin['content'] .= "<?php include('pages/page_$pagename.src'); ?>";[/code]In Page:[code]<td class='nav_body' nowrap> <br> <? echo $skin[content]; ?> <br> </td>[/code]Now, I've tried all sorts of things and cannot get this to execute a function while echo'ing it. Nothing has worked, most I've got it to do is echo the text.If you could please help me out, I would appreciate it greatly!Thank you very much.-Ryan Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/ Share on other sites More sharing options...
Zane Posted May 14, 2006 Share Posted May 14, 2006 look at the exec() function[a href=\"http://www.php.net/exec\" target=\"_blank\"]http://www.php.net/exec[/a] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35595 Share on other sites More sharing options...
mysticssjgoku4 Posted May 14, 2006 Author Share Posted May 14, 2006 I don't understand how I'm supposed to use that.I don't even think it would work for what I'm trying to achieve :-\.I want it so that I can echo text and/or call a function through a variable.Have any examples?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35598 Share on other sites More sharing options...
Zane Posted May 14, 2006 Share Posted May 14, 2006 instead of echouse execsimple as that[code]exex($skin[content]);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35599 Share on other sites More sharing options...
toplay Posted May 14, 2006 Share Posted May 14, 2006 You want to use eval():[a href=\"http://us2.php.net/manual/en/function.eval.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.eval.php[/a] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35600 Share on other sites More sharing options...
mysticssjgoku4 Posted May 14, 2006 Author Share Posted May 14, 2006 Thank you, eval worked perfectly. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]One thing, I'm not sure if it's my fault or what:I put this inIndex.php[code]$skin['content'] .= "include('pages/page_$pagename.src');";[/code]Page Included[code]<? $skin['title'] = "News";?><p align='center'><table width='95%' border='1'> <tr> <td> </td> </tr> <tr> <td> CENSORED<br> </td> </tr></table></p>[/code]Template[code]<td class='nav_body' nowrap> <br> <? eval($skin[content]); ?> <br> </td>[/code]Doesn't set the value $skin['title'] to "News" as it should above.Thank You once again! Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35603 Share on other sites More sharing options...
_will Posted May 14, 2006 Share Posted May 14, 2006 try[code]$skin['content'] .= "eval(include('pages/page_$pagename.src'));";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35629 Share on other sites More sharing options...
mysticssjgoku4 Posted May 14, 2006 Author Share Posted May 14, 2006 That didn't work and I get an error with that[code]Parse error: parse error, unexpected $end in C:\HLServer\Apache2\htdocs\dba\skins\default\style_layout.src(63) : eval()'d code(1) : eval()'d code on line 1[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35640 Share on other sites More sharing options...
trq Posted May 14, 2006 Share Posted May 14, 2006 You might want to watch your tongue when posting on the forums. Some people may take offence. I would edit your previous post if I where you. Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35643 Share on other sites More sharing options...
mysticssjgoku4 Posted May 14, 2006 Author Share Posted May 14, 2006 [!--quoteo(post=373675:date=May 14 2006, 02:14 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 14 2006, 02:14 AM) [snapback]373675[/snapback][/div][div class=\'quotemain\'][!--quotec--]You might want to watch your tongue when posting on the forums. Some people may take offence. I would edit your previous post if I where you.[/quote]Not only is it an example, it's a quote from television. If it was able to be air'd I don't believe anyone will take offense to it and would rather laugh at it. Good Day, and thank you for going off topic while not providing me any help. I can see the relevance you must make amongst the community.Now aside from all that, does anyone have any better ideas? [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35737 Share on other sites More sharing options...
trq Posted May 14, 2006 Share Posted May 14, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]I don't believe anyone will take offense to it[/quote]Im telling you that I [b]do[/b].[code]$skin['content'] = "include('pages/page_$pagename.src')";eval($skin['content']);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35740 Share on other sites More sharing options...
toplay Posted May 14, 2006 Share Posted May 14, 2006 Well, I don't really see what you're doing exactly since you don't show where $skin['title'] is echoed/printed.Think about using a template engine like Smarty instead. Quote Link to comment https://forums.phpfreaks.com/topic/9631-executing-php-function-through-echod-variable/#findComment-35750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.