How can the header function be used for redirection in PHP scripts?
To perform a redirection in PHP scripts, the header function can be used to send a raw HTTP header to the browser. This function is typically used to redirect users to a different page or URL. By setting the "Location" header with the desired URL, the browser will automatically redirect the user to that location.
<?php
// Redirect to a different page
header('Location: https://www.example.com');
exit;
?>
Related Questions
- What is the significance of using mysql_error() in PHP?
- What best practices should be followed when retrieving and displaying Facebook posts in PHP?
- What are some alternative methods for handling line breaks in PHP text files to ensure cross-platform compatibility, especially for end-users on Windows operating systems?