Home > Backend Development > PHP Tutorial > What is the use of the short opening tag '

What is the use of the short opening tag '
青灯夜游
Release: 2023-04-05 13:30:01
Original
9326 people have browsed it

In PHP, "PHP tutorial]

What is the use of the short opening tag '<?=' in PHP?

In php, whenever it reads the php document, it will look for:

<?php ?>
Copy after login

It only processes the code between the above tags and leaves other code around them.

Example:

<?php 
echo "Hello PHP !"; 
?>
Copy after login

Output:

Hello PHP !
Copy after login

However, in fact, when using echo() for output, we can use shortcut methods. The above example can be output using the

<?= "Hello PHP !"?>
Copy after login

Description: "

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
Copy after login

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 "

Example 1: Normal way output

<?php 
    $username = "php中文网"; 
    echo "$username"; 
?>
Copy after login

Output:

php中文网
Copy after login
Copy after login

Example 2: Use: "

<?php 
    $username = "php中文网"; 
?> 
<?= $username ?>
Copy after login

Improvement Click:

<?= 
$username = "GeeksforGeeks"; 
?>
Copy after login

Output:

php中文网
Copy after login
Copy after login

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 '

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template