Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between <?php and <?

Tags:

syntax

php

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

<?php ?> 

and

<? ?> 
like image 992
Jey Geethan Avatar asked Nov 27 '09 12:11

Jey Geethan


People also ask

What is <? php tag?

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.

Is there a difference between and in php?

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.

What is the difference between a string and string in php?

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

How do I end a php script?

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


1 Answers

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.

like image 160
erenon Avatar answered Oct 11 '22 06:10

erenon