I can't find the answer anywhere. Thanks!
Basically,
<? ?>
<? ?>
are short tags. However, not every php installation has short tags enabled. Therefore, even though is faster to type than the normal tags ( <?php ?>
), it may not work if you move your code to another server.
Are PHP short tags acceptable to use?
EDIT: Also, if you're using xml in your web page, you might run into conflicts, as writing <?xml version="1.0"?>
will make you run into a PHP error, as xml version="1.0" isn't PHP!
If you're using XML and PHP you may need to <?php echo "<?xml version=\\"1.0\\""; ?>
<?php echo "<?xml version=\\"1.0\\""; ?>
In your php.ini, if you want <?
and ?>
to work, you need to turn on "short tags". However, it is better to write long-tag compliant code in the first place.
Acutally is no difference.
They both mean the same, with the difference that the short form <? ?>
<? ?>
is not always supported/enabled.
There acutally is no difference between the two, the second one is bascially just a shorthand. I personally would recommend using the longer version, because on some systems, the second possibilty is disabled in the php.ini
(see short_open_tags
).
It is always better to use <?php ?>
as on some installations of php <? ?>
<? ?>
is not supported! If this happens your code will not work!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.