Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php check if headers already sent

<?php
  
//You can use 'headers_sent' function 

// If no headers are sent, send one
if (!headers_sent()) {
    header('Location: http://www.example.com/');
    exit;
}

// An example using the optional file and line parameters
// Note that $filename and $linenum are passed in for later use.
// Do not assign them values beforehand.
if (!headers_sent($filename, $linenum)) {
    header('Location: http://www.example.com/');
    exit;

// You would most likely trigger an error here.
} else {

    echo "Headers already sent in $filename on line $linenum
" .
          "Cannot redirect, for now please click this <a " .
          "href="http://www.example.com">link</a> instead
";
    exit;
}

?>
Comment

PREVIOUS NEXT
Code Example
Php :: random 6 digit number php 
Php :: array_push in php 
Php :: php last day of month 
Php :: wp redirect 
Php :: get am pm 12 hour timee laravel 
Php :: php constant array 
Php :: getMessage in php 
Php :: php info 
Php :: wordpress custom post type add post_tag 
Php :: get country from ip address 
Php :: php days in month 
Php :: laravel redirect with message to section 
Php :: php round to whole number 
Php :: construtor php 
Php :: ubuntu laravel storage permission 
Php :: scribe laravel 
Php :: session cakephp 
Php :: alerta con php 
Php :: Modes for File Read PHP 
Php :: delete directory from laravel storage 
Php :: php end session 
Php :: php cut string 
Php :: woocommerce show data to cart page 
Php :: convert date to timestamp in laravel builder 
Php :: insert data using mysqli in php 
Php :: symfony header token authorization 
Php :: php count matching words in two strings 
Php :: collapse open by default 
Php :: make table in laravel 
Php :: php boolean to string 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =