Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- The One Line Template Engine!


vincevincevince - 1:09 am on Sep 13, 2007 (gmt 0)


mooger35, you can do that - or there are two other options:

1) Inside 'somefile.php', everywhere you see 'print' or 'echo' change it to '$text.=' - this will mean you can just do include('somefile.php'); and $text will be filled with the output:

print "Good morning $name"; ==> $text.= "Good morning $name";

2) Use a http:// request to file_get_contents(). $text=file_get_contents("http://your.example.com/somefile.php"); - this runs it as a separate Apache instance and you get the full results to variable

Your solution is fine, apart from it being a whole extra function to define. Be careful though as your variable scope is still shared, e.g. if you set $a=7 in somefile.php, $a still equals 7 afterwards.


Thread source:: http://www.webmasterworld.com/php/3444822.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com