Do not write at the end of the PHP file?> Which of the following are the benefits?

Source: Internet
Author: User
Do not write at the end of the PHP file? What are the benefits of & amp; gt;

  1. // This is B. php
  2. Include a. php
  3. Session_start ();
  4. ?>

I have seen that many php files do not contain the php Terminator. today I see a demo, which just Explains No.> The benefit of the Terminator.

The following is a. php:

Pay attention to the fourth line, the fifth line)

  1. Include File. php
  2. Session_start ();
  3. ?>

When you run the second file, you will find it throws a warning saying that header already send out

The main reason is that a. php still has several blank lines after the PHP Terminator is called, so PHP will regard it as html code. does it have header output before session_start is called. No output is allowed before session_start is called, so the program will throw a warning.

If you use?>, This error may be made inadvertently. when the project is large and the code is large, it is very difficult to find such a problem. Therefore, it is best not to write the php file?>, This is the practice officially recommended by zend.

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.