PHP tags <?php?> the end tag is necessary to add

Source: Internet
Author: User
Remember before during the training, the instructor told us that the end tag of PHP?> can not be added, and it is best not to add, said in some cases is necessary (forget what is the case)
What do you think of Daniel?
[PS: Of course, in the case of PHP mixed with HTML, it is bound to add the end tag]

Reply content:

Remember before during the training, the instructor told us that the end tag of PHP?> can not be added, and it is best not to add, said in some cases is necessary (forget what is the case)
What do you think of Daniel?
[PS: Of course, in the case of PHP mixed with HTML, it is bound to add the end tag]

cc:http://segmentfault.com/q/1010000000437998#a-1020000000438006

http://www.php.net/manual/zh/language.basic-syntax.phptags.php

If the file content is pure PHP code, it is best to remove the PHP end tag at the end of the file. This avoids having to accidentally add a space or line break after the PHP end tag, which causes PHP to start outputting these blanks, and there is no intention to output the script at this time.

The end of the end of the PHP tag is removed, first you must ensure that your script must be all written in PHP, and then get a definite answer, I think the end of the tag is not to delete this is all personal habits.
Generally speaking, a lot of programmers will not add, because the benefits of doing this can avoid a lot of code compile in the time of the strange strange error, and you remove?> but do not error, but you do not know what reason ...
This is my habit, I hope it will help you.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.