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
2
Answers
I think your approach is pretty basic (you try to hardcore modify – programmerly edit – the template script, right?) but anyway:
To get the desired output :
Output will be
output string
notfile string
: