Difference between <?php and <?

Viewed 20948

I am new to php and would like to know if there are any differences between these server tags :

<?php
?>

and

<?
?>
7 Answers

As @erenon explained here: https://stackoverflow.com/a/1808372/1961535

The difference is that short_open_tag in some cases isnt available. You can check the status by accessing the php.ini file but in case of shared hosting server, the host does not always allow edits to php.ini file.

You can easily print the phpinfo as explained here: https://www.php.net/manual/en/function.phpinfo.php

phpinfo();

search for short_open_tag as shown below

enter image description here

It is always better to use full tag because that will always be supported in every version of PHP weather old file or new.

Related