March 24, 2012
Activating a php file from another php file
Question by Sedat KURT
I have abc.php and def.php files.For example I want to call def.php from abc.php .I found include() method but I don’t want def.php to activate in background.I want browser to redraw the page according to html-php codes of def.php
Any ideas ?
Answer by Starx
You can return the content of def.php
Here is an example:
Page: def.php
<?PHP
//do many things, but do not echo or print anything
$output ="<div> all the codes</div>"; // collect the markup like this
return $output; // return the output but still do not echo or print
?>
Now Page: abc.php
//do its own processing
$myDefPageOutput = include("def.php");
//This will only get the values of the return statement
//Now user $myDefPageOutput wherever you want and redraw the page