is it possible to make something like this?
// file.php
$string = require('otherfile.php');
echo $string;
// otherfile.php
<!DOCTYPE html>
<html>
<head><title>Test</title></head>
<body>
<?php require 'body.php';?>
</body>
</html>
// body.php
<p>Lorem ipsum something</p>
And get this output?
<!DOCTYPE html>
<html>
<head><title>Test</title></head>
<body>
<p>Lorem ipsum something</p>
</body>
</html>
I know that code won't work, but I hope you understand what I mean.
file.php
ob_start();
include 'otherfile.php';
$string = ob_get_clean();
$string = file_get_contents('otherfile.php',TRUE);
echo $string
Use of the TRUE argument for file_get_contents() means it will search using the include path, like a normal include or require
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