When using the php include function, how can I display html code on a new line/line break?
For ex:
HTML CODE
<?php include("file.php");?>
HTML CODE
Will print HTML CODE<?php include("file.php");?>HTMLCODE
Any way to fix this? I know I can add additional line breaks in the php file itself, but in practice of professional programming(everyone does it in their own way), what’s the best way? I would like to see multiple solutions.
An actual example from my code
<!DOCTYPE html>
<html>
<head>
<title>PAGE - TITLE</title>
</head>
<body>
<div class="page-content">
About us page<br></div></body>
</html>
It’s not clear from your example what’s in the actual include file, but you shouldn’t get the result you are suggesting—unless perhaps the “HTML code” is not actually code but just text.
Do you mean that when you view the source code in your browser, you want the code to be properly formatted with proper line breaks? If that’s the case, use \n where you want the code to break to a new line.