I found this function in some script and couldn't get what is the use of it:
class DemoController extends Controller {
public function indexAction() {
$content = include('../index.php');
return array ('content' => $content);
}
}
What is the use to include PHP script into variable? Is it a kind of a design pattern? Can anyone drive to the right direction?
My guess is that index.php
is building up the markup for the page, and then return
ing it. This is a nice clean way to generate the markup and include it as a string in whatever script may want to use it.
See: http://php.net/manual/en/function.include.php#example-158
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With