I want to render a php file through another php file.
I have two php files. One defines a class. Another one holds both html and php. For the sake of better understanding, I am providing a demo code.
file1.php
<?php
class someClass
{
public function someMethod()
{
echo readfile('file2.php');
}
}
file2.php
<?php
$block = 'block';
echo $block;
?>
<div>djkdjkjkjfkjkdjfkjk</div>
index.php
<?php
require_once 'file1.php'
$class = new someClass();
$class->someMethod();
When I load www.domain.com
, Output is as follows
djkdjkjkjfkjkdjfkjk 71
That is my method is not parsing php codes correctly. How can I echo content of file2.php
in normal way (as we just see the output for www.domain.com/file2.php
)?