Quick Tip: PHP Open Tags

Did you know there are five different ways to show the beginning of a block of PHP code?

<?php print("hello world"); ?>
<? print("hello world"); ?>
<?="hello world"; ?>
<% print("hello world"); %>
<script language="php"> print("hello world"); </script>

The first one is the most popular, and does not cause any problems with syntax clashing.

Note: To use the shorthand notation (<?) you must have short_open_tag directive on in your php.ini file.

Please subscribe, or else I will cry. Do you really want to make a programmer cry?

Leave a Reply

Note: By submitting your comment you agree to this blog's comment policy.

If you want a little icon next to your name - sign up for one at Gravatar.