使用PHP在函数内打印HTML而不使用echo

I've no clue if what I want is possible so a "no is not possible" could also be an answer for me.

Im making a PHP function like this:

<?php
function set_block_title($post){
    echo "<p class='title'>$post->get_title()</p>";
}

I would like to do this without an echo and instead get the html out of the PHP page (mainly because the designers who will break all the PHP when they don't have the HTML syntax).

I know it's possible with an if statement like this:

<?php if( condition ): ?>
    <p class='title'>
        <?php echo $post->get_title(); ?>
    </p>
<?php endif; ?>

Is there a way to do the same thing with a PHP function? I suppose I could do something like this:

<?php
function set_block_title($post){
    <?php if( true ): ?>
        <p class='title'>
            <?php echo $post->get_title(); ?>
        </p>
    <?php endif;
}?>

you can do this way also.

<?php
function set_block_title($post){
   $html = "<p class='title'>$post->get_title()</p>";
  return $html;
}
?>

try above code may helps you.

There is another way of printing a php variable in your html:
instead of using:

"php echo $variable;"


you can use:

php =$variable;"

You could try this: Steps required BEFORE doing this are -- 1) A template file, preferably with the extension of PHP. 2) Basic knowledge of PHP. -- This is the fastest way.

$tmplt = readfile("PageTemplate.php");
echo $tmplt;

I hope I helped! Read up on the Readfile function at PHP.net - Readfile -- By the way: I know you asked for no echo, but you also asked to see the html syntax, so despite this having echo, it will still have the marks and everything. Sorry!