省略用于打开标签的单词php

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).

It works right, but is there any consequence/bad programming practice?? there is no problem?? is everything ok? what can it happen?

Well, not every hosting allows short-open-tag. So <?php is a better option if your script target large audience. Or you often change your hosting.

if short_open_tag is open, the short form (<? ?>) will work.

anyway the long form is a standard.