I am new to php and would like to know if there are any differences between these server tags :
<?php ?>
and
<? ?>
The <= tag is called short open tag in PHP. To use the short tags, one must have to enable it from settings in the PHP. ini file.
The difference is, strings between double quotes (") are parsed for variable and escape sequence substitution. Strings in single quotes (') aren't. The same in single quotes returns the literal string. you would probably use single quotes, to avoid having to escape the quotes in the string and vice-versa.
string in php is not an object, which mean, you can't use method like equals or other that can be use in java. string in php is a type as well as float, int ...
The closing tag of a block of PHP code automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block. The closing tag for the block will include the immediately trailing newline if one is present. <?
The first is a safe open and close tag variation, the second is the so called short-open tag. The second one is not always available, use the first option if it's possible. You could check the availability of short open tags in php.ini, at the short_open_tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With