Is it possible to execute PHP code into variable? For example I have index.php and page.php files in the same directory. If you execute page.php you will have a part of HTML page. I want to put this as a string into a variable in index.php.
Any suggestions?
Is it possible to execute PHP code into variable? For example I have index.php
Share
You can use the output buffer:
Mind that page.php is still executed in the same context (global variables, functions etc. continue to exist)
In general doing something like that sounds like broken design and page.php should be rewritten properly.