How can you pass parameters in the header() function in PHP?
When using the header() function in PHP to pass parameters, you can include them in the URL as query parameters. This can be done by appending the parameters to the URL using the "?" symbol followed by the parameter name and value pairs separated by "&" symbols. By doing this, the parameters will be passed in the header of the HTTP response and can be accessed by the destination page using PHP's $_GET superglobal array.
// Example of passing parameters in the header using the header() function
$param1 = 'value1';
$param2 = 'value2';
header("Location: destination.php?param1=$param1&param2=$param2");
exit;
Keywords
Related Questions
- How can a random string be generated using characters A-Z and 1-9 in PHP?
- Are there any specific best practices recommended for properly formatting PHP code when generating HTML elements like SELECT?
- In what scenarios might a PHP website be accessible on certain devices (e.g., iPhone) but not on others?