External PHP file - parcing data from echo outside the doctype in a HTML file -
i have 2 files: file1.php , file2.html. in file1.php have:
... //some variables $title , $message echo '<p><h1>' . $title . '</h1></p>' . '<p>' . $message . '</p>'; require('file2.html'); ...
and want echo
in center
tag of html page. here's happens when open file2.html in browser:
<p><h1>title</h1></p><p>message</p> <!-- , doctype comes after php input. ruins whole code --> <!doctype html> <html dir="ltr" lang="en-us"> <head> <title>example</title> <script type="text/javascript" src="/scripts/script.js></script>" </head> <body style="background-color: #fbfbfb;"> <p><a href="/" title="home">home</a></p> <p><a href="/contact.html" title="contact us">contact us</a>.</p> <p><a href="/forums/" title="forums">forums</a></p> <center> </center> </body> </html>
your code echo title used before displaying "..."
your main page should had php extension instead of html. after changing extension insert code html tags that:
<center> <?php echo '<p><h1>' . $title . '</h1></p>' . '<p>' . $message . '</p>'; require('file2.html'); ?></center>
Comments
Post a Comment