PHP: header

Posted in PHP on 26 May 2017
header($string);

Used to send a raw HTTP header, often used for page redirects.

Must be called before any other output is sent.

// Redirect the request to https://keithgreer.dev
header("Location: https://keithgreer.dev");
// Send an error code to the browser, for example a 404
header("HTTP/1.0 404 Not Found");

Related PHP Posts

August 2021

Google Sheets to PHP Array

This PHP function accepts a public Google Sheets URL and converts it into a PHP array. You can use the array to either display the... Continue reading

March 2021

PHP cURL Requests with JSON or XML

The following post will explain how to use PHP/cURL to retrieve data in JSON or XML and process it for using in your PHP application... Continue reading

February 2021

Global Payments: Strong Customer Authentication (SCA) and 3D Secure 2

The roll out of 3D Secure 2 has been a long drawn-out process not helped by the COVID–19 pandemic. Part of the update has included... Continue reading

More PHP Posts