Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between closed tags and unclosed tags in php

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the difference between closed tags and unclosed tags in php". The content in the article is simple and clear, and it is easy to learn and understand. Please follow Xiaobian's train of thought to study and learn "what is the difference between closed tags and unclosed tags in php".

Php > want the difference: 1, to close the label, it will cause redundant output, php errors or blank pages, etc.; 2, do not close the tag, you can prevent the harmful content after closing the tag; 3, if it is mixed use, or to write a closed label.

The operating environment of this paper: Windows7 system, PHP7.1, Dell G3.

Php > what are the differences between whether you want it or not? What are the benefits of not writing closed tags on php?

When I first wrote PHP code, I was going to write PHP closed tags, and over the past few years, my habit has changed and I no longer write PHP tags.

I first came across this concept from Drupal, and I was a little unaccustomed at first-why not write a closed tag? It doesn't feel perfect, and it's not suitable for people with obsessive-compulsive disorder. Later, in the work encountered problems caused by the closure of the label, began not to write a closed label.

Refer to some articles and summarize the PHP closing tags as follows:

Benefits:

If this is a program that is included by others, without this Terminator, you can reduce a lot of problems, such as: header, setcookie, session_start, these actions can not have output, if you accidentally add invisible characters (extra spaces, newline characters) after the? > to destroy the page display, it will report a "Header already sent" error, if you do not write, there will be no such problem. Alternatively, you can move the cursor directly to the end and then program.

Disadvantages:

In dreamweaver view mode, it's a mess.

The official explanation for the PHP closed tag is: the PHP closed tag "?" the parser for PHP is optional in PHP. However, if you use closed tags, any spaces after closed tags inserted by developers, users, or FTP applications may result in extra output, php errors, subsequent output not being displayed, and blank pages. Therefore, all php files should omit the php closure tag and insert a comment to indicate that this is the bottom of the file and locate the relative path of the file in this application. This helps you to make sure that the file is finished rather than abridged.

Code example:

Inappropriate:

The code is as follows:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report