Change language

Refresh the page with PHP

Syntax:
void header ($header, $replace = TRUE, $http_response_code) Or header (string, replace, http_response_code) 
Options:
  • $header:contains the header line. There are two types of header calls. The first header begins with the string "HTTP /", which is used to define the HTTP status code to send. The second case of the header - "Location:". This is a required parameter.
  • $replace:this is an optional parameter. It means that the heading should replace the previous one or add a second heading. The default is True (override). If $replace is False then it forces multiple headers of the same type.
  • $http_response_code:This is an optional parameter. This forces the HTTP response code to the specified value (PHP 4.3 and up).
Note.This function prevents multiple headers from being sent at the same time. This is a defense against header attacks after PHP 4.4.Here’s an example of using header() to refresh the current page in PHP:Example. Inthis example uses the header() function to refresh the web page every 3 seconds.  
// Demonstrate using the header() function
// refresh current page echo "Welcome to index page
"
; echo "Page will refresh in every 3 seconds

"
;  
// The function will refresh the page
// every 3 seconds header ( "refresh: 3" ); echo date ( ’ H: i: s Ymd’ ); exit ; ?>
Output: document.createElement (’video’); < / source> Example 2: In this example uses the header() function to redirect a web page to another page.  
// Demonstrate using the header() function
// update the current page echo "Welcome to index page
"
;
echo "we will redirect to GeeksForGeeks Official website in 3 second" ;  
// The function will be redirected to the official engineerforengineer site header ( "refresh: 3; url = https://www.engineerforengineer.org/ " ); exit ; ?>
Output: Links: https://www.php.net/manual/en/function.header.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method