I am trying to include file in string replace but in output i am getting string not the final output.
analytic.php
<?php echo "<title> Hello world </title>"; ?>
head.php
<?php include "analytic.php"; ?>
index.php
string = " <head> </head>";
$headin = file_get_contents('head.php');
$head = str_replace("<head>", "<head>". $headin, $head);
echo $head;
Output i am getting :
<head><?php include "analytic.php"; ?> </head>
Output i need :
<head><title> Hello world </title> </head>
Note : Please do not recommend using analytic.php directly in index.php because head.php have some important code and it has to be merged analytic.php with head.php and then index.php
file_get_contentsonly reads the file content, it does not put that content through the PHP parser.<head><?php include "head.php"; ?></head>? Please show me the detail if you can't.analytic.phphave analytic code from Google analytic, Microsoft clarity, and other analytic.head.phphave many code including javascript and css linking. All are in different folder. So, i am trying to include all the analytic code inhead.phpand thanhead.phpinindex.php$headin = include "analytic.php";. What is the solution to it?head.phpinindex.php.