What does a special set of tags <?= and ?> do in PHP?

I did a search and found an article that explains it (see link below).
<?= is a shortcut for echo. It only works if PHP's short open tags is turned on. This isn't much of a shortcut (especially since you also need the closing tag for a total of 5 characters to replace 5 if you count the closing semi-colon for the echo). It might be better termed as an alternative.

The ?> is the standard PHP closing tag. Normally, your code will be something like:

<?PHP
... a bunch of PHP code ...
?>

If you use the short open tags (not recommended) then this would be:
<?
... a bunch of PHP code ...
?>

You can also break in and out of PHP (by enclosing the PHP in open and closing tags wherever it appears) and include HTML / Javascript code in the same module.

http://perishablepress.com/press/2009/01/12/php-short-open-tag/

To elaborate on that Below are three examples of doing the same thing

<?="Hello World!"; ?>
<? echo "Hello World!"; ?>
<?php echo "Hello World!"; ?>

Now as you should know they all do the same thing providing php is configured correctly. However as of Php 5.3.0 in xampp the <? command is depreciated and instead you must use the <?php method. This means by default you would need to use the echo statement unless you go into the php.ini settings and enable short tags. But then as of Php 6.0 short tags are completely removed from php making it impossible to enable it again. So if you wish for your code to be compatible and php 6 compliant then the only option is to use the following method.

<?php echo "Hello World!"; ?>

Now a lot of people reading this might say wtf php 6 hasn't been released yet. Well php 6 has been documented at the php.net website and the expectations of php 6 have already been released but not the C/C++ code itself.

<?php echo "Hellow World"; ?>

is the same as:

<?= "Hello World" ?>

<?php echo "Hellow World"; ?>

is the same as:

<?= "Hello World" ?>

Except <?= "Hello World" ?> is depreciated.

Member Avatar for diafol

Deprecated tags. You gotta love 'em. I see your original post has attracted a number of neg reps. I assume members think that you should have used Google or looked up the php manual before posting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.