Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<?php instead of <?

Tags:

syntax

php

Why should I use <?php instead of <? in my php script?

like image 645
Bigballs Avatar asked Feb 10 '09 16:02

Bigballs


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. First of all ensure that short tags are not disabled, To check it, go into php.

How do I end a PHP tag?

As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement. 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.

What does colon mean in PHP?

In PHP, the double colon :: is defined as Scope Resolution Operator. It used when when we want to access constants, properties and methods defined at class level. When referring to these items outside class definition, name of class is used along with scope resolution operator.


1 Answers

The two main reasons to avoid the short opening tag are

  1. Maximum portability - <?php will work on every PHP enabled server, but <? can be disabled
  2. It's identical to the opening of the XML preamble - could cause parsing or execution headaches
like image 127
Peter Bailey Avatar answered Oct 06 '22 00:10

Peter Bailey