I need to display the content of another page from a function using return.
What is the best way to do this?
Say that I have file.php. In my script in another page, I want to call a function and return the contents of file.php.
For example:
myFunction() {
$page = WHAT('file.php');
return $page;
}
What to use in place of ‘WHAT’? I’ve tried include, because it’s what I know, but it doesn’t work here.
EXTRA NOTES: This is used in a Drupal module. The admin theme / menu displays as normal if I use $page = 'insert code here'; return $page; – but not if I use $page = include('file.php'); because the function doesn’t even use the return when it sees 'include'.
for code or content of file use: file_get_contents
for instant result of another php page, you can try ob_start and
ob_get_clean.It will gather the output of the included file in memory and later you can gather the output to variable and clean the memory or just show the output directly.
like: