In PHP, "PHP tutorial]
In php, whenever it reads the php document, it will look for:
<?php ?>
It only processes the code between the above tags and leaves other code around them.
Example:
<?php echo "Hello PHP !"; ?>
Output:
Hello PHP !
However, in fact, when using echo() for output, we can use shortcut methods. The above example can be output using the = tag, for example:
<?= "Hello PHP !"?>
Description: "=" is a short open tag in PHP and is a shortcut for echo().
If you want to use this short tag, you must enable it from the settings in the PHP.ini file.
We need to find the following line in the PHP.ini file and add (On) to turn it on,
short_open_tag=On
However, starting from PHP version 5.4.0, regardless of the settings in the PHP.ini file Either way, short tags can be used.
Note: If you want to use XML at the same time, you can disable this option to facilitate embedded use , or you can output it through PHP. For example: ='
Let's take a look at how "=" is used through code examples.
Example 1: Normal way output
<?php $username = "php中文网"; echo "$username"; ?>
Output:
php中文网
Example 2: Use: "="
<?php $username = "php中文网"; ?> <?= $username ?>
Improvement Click:
<?= $username = "GeeksforGeeks"; ?>
Output:
php中文网
The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !
The above is the detailed content of What is the use of the short opening tag '=' in PHP?. For more information, please follow other related articles on the PHP Chinese website!