Whether the PHP header should have exit after

Source: Internet
Author: User
Tags exit header php file

PHP header after the need to write exit to terminate the program, has not been too concerned about the past, today encountered a bug, just found that this is still a problem, deliberately wrote a paragraph of code test, the code is as follows:

<?php
Header ("location:http://www.alixixi.com/");
Exit ();
File_put_contents ($_server[' document_root '). Directory_separator. " N.txt ", ' PHP Programmer tutorial Web ', LOCK_EX);

The results show that if the PHP file runs with header ("Location: a page URL"), this statement will jump directly to another page, but the jump does not affect the continuation of the current PHP file. That is, after the PHP header jumps, the script for the current page continues to execute. If you need to terminate the script operation, you need to add exit () or Die ().

Articles that you may be interested in

  • PHP get_headers to determine if the URL is valid
  • PHP with header () implementation file download, download the file hint is broken can not open the solution
  • function and usage of PHP get_headers function
  • PHP Analog get_headers function
  • Use and difference in PHP to jump out of multiple loops using Break,continue,goto,return,exit
  • PHP header 404 Jump error page
  • PHP finds whether a value exists in the array (In_array (), Array_search (), array_key_exists ())
  • Summary of usage of PHP header


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.