I mean:
<?php echo "hello"; ?>
against:
<? echo "hello"; ?>
(without the php
).
It works right, but is there any consequence/bad programming practice?? There is no problem?? Is everything OK? What can happen?
I mean:
<?php echo "hello"; ?>
against:
<? echo "hello"; ?>
(without the php
).
It works right, but is there any consequence/bad programming practice?? There is no problem?? Is everything OK? What can happen?
Paraphrased from the PHP manual:
<?php
should always work.<?
only works if short_open_tag = On
in php.ini
.<?=
(equivalent to <?php echo
) should always work in PHP 5.4 and newer. In PHP 5.3 and older, it does require short_open_tag = On
.So if you are writing a PHP app for others to use, it is best to stick with <?php
(and <?php echo
if you decide to support PHP 5.3 or older). If you can control the server's configuration, you can use <?
if you want to.
Use, for example, <?php echo '<?xml version="1.0"?>'; ?>
if you have to output an XML prolog or processing instruction manually (as opposed to using PHP's XML functions to do it).