<?php
echo '<div class="prcf_header">My included text</div>';
?>
As can be understood from the first code example, I use lots of echo commands there; in practice I need something better than just echoing every line because I normally work with much longer HTML codes.
I thought about using an heredocument, but it will desolate the include command.
How to properly format the first file so I would not need echo commands to output direct HTML, but in such a way that won’t prevent the include command from working?
If the content of the include is simply just HTML, you don’t need the PHP tags or echo, it could simply be pure HTML:-
<div class="prcf_header">My included text</div>
So the include can be used to reduce repetition in the page such as a menu which is identical in all pages, any edit to it only need be done once.
Though if your include contains variables or logic, it can include PHP within it.
<div class="prcf_header">My included text about <?= $textSubject ?></div>
But the best way of doing things depends on the context of what it is you intend to do.
Indeed, in my .php files, eventually I removed all echo commands and their syntax and stayed with just pure HTML and PHP code such as include 'FILE'; just where I needed it and my code works fine this way.