Are there any alternative methods to include a target when redirecting in PHP, besides using JavaScript?

When redirecting in PHP, the standard method is to use the header() function to send a Location header with the target URL. However, if you need to include a target attribute (e.g., _blank) when redirecting, you can achieve this by using a meta refresh tag in the HTML output of the redirected page. This can be a workaround to include a target without relying on JavaScript.

<?php
// Redirect to the target URL
$targetUrl = 'https://example.com';
header('Refresh: 0; URL=' . $targetUrl);
?>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;url=<?php echo $targetUrl; ?>" target="_blank">
</head>
<body>
</body>
</html>