Hi, What I mean by the question is if i have some thing like $script = "<? echo \"\nHello World!\"; ?>" // I Want to compile the above string here or just include it here PHP:
hmm, can you be more specific? but basing on your sample it seemed that you just want to run a php line, then the above code will work, assuming you have php setup with your webserver(usually apache)
What I want to do now is to include the code that '$script' has into a function .... what i am trying to do is a template substitution , that is there are some variables that come at runtime to a function and that function has a predefined string. Function just has to substitute the arguments (array with keys and values) and return whatever was evaluated by that 'script' string .. am I clear??
function doSomething($func) { echo "Hello "; eval($func); } $func = "echo 'World!';"; doSometing($func); like that?
a more elaborate example: function subst ($list) { $script = "$feed = \"\"; foreach ($list as $user) { $feed +="\nHello $user!\"; }"; //include the $script here and use $list to substitute //one simple thing i can do is to write $script to some file and include that file //i will get some output to $feed and that is what i want } PHP:
exactly!! Thanx Mr. Kwaku!! I was a fool not to think of 'eval', because it is availble in python and i was using python too ...