将PHP中的esc_html命令与HTML结合使用

Is it possible to combine specific commands from PHP with styles? I display data via following command:

echo esc_html( $text )

How is it possible to display the data like a headline <h3> tag?

I tried to simply add it, but that does not work:

'<h3>' . echo esc_html( $text ) . '</h3>';

Any ideas?

You may want to check Escaping from HTML. In your case:

<h3><?php echo esc_html($text); ?></h3>

Alternatively, just feed echo with as many arguments as needed:

<?php
echo '<h3>', esc_html($text), '</h3>';