Reputation: 9293
01.php
<div class='title'>title</div>
02.php
<?php include('01.php');?>
some function:
$a = file_get_contents('02.php');
echo $a;
Result:
<?php include('01.php');?>
Is there a way to refer 02.php
(without including it in the current file) and get this:
<div class='title'>title</div>
This is a simplified example. In reality 02.php
is a large file with 01.php
included somewhere inside.
Upvotes: 0
Views: 126
Reputation: 26
If you want to parse the php file and save the result to a variable instead of outputting it you could use:
ob_start();
include("01.php");
$a = ob_get_contents();
ob_end_clean();
You will have the parsed php in $a but it will not be output to the user. More info: http://php.net/manual/en/ref.outcontrol.php
Upvotes: 1