Simple Shortcut to PHP echo – Keep it Neat and Tidy

Last Updated on: February 11, 2023

Try this for a simple way to echo a variable in your HTML template files:

<?= $variable ?>

You can also use this to show the return value of a function:

<?= functionThatReturnsSomething() ?>


This requires the PHP directive short_open_tag to be set to 1 (done via php.ini or .htaccess).

Most hosts will have this set to 1 by default although there are some that will stop this altogether – keep this in mind if your code is to be widely used.


Get notified of new posts:


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *