How to use headers sent in PHP

In this article I am going to explain about headers_sent function in PHP.
  • 1599

PHP headers_sent() Function

The HTTP headers_sent function checks where the HTTP headers have been sent.

Syntax of headers_sent  function

headers_sent(file, line)

Parameters in headers_sent function

It have two parameter:

Parameter Description
file It is optional parameter and it will put the PHP source file name and line number where output started in the file variable.
line It specifies the line number where the output started.

Example of http headers_sent function

<?php

if (!headers_sent())

  {

  header("Location: https://dotnetheaven.com/");

  exit;

  }

?>


You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.