What are some common header settings that can be adjusted using the header() function in PHP?

When working with HTTP headers in PHP, the header() function is commonly used to set various header settings. Some common header settings that can be adjusted using the header() function include setting the content type, redirecting the user to a different page, setting cookies, preventing caching, and setting the HTTP response code.

// Setting the content type to JSON
header('Content-Type: application/json');

// Redirecting the user to a different page
header('Location: http://www.example.com');

// Setting a cookie with a value that expires in 1 hour
setcookie('cookie_name', 'cookie_value', time() + 3600);

// Preventing caching of the page
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');

// Setting the HTTP response code to 404 (Not Found)
http_response_code(404);