Im getting syntax error when adding php code to javascript. I think I did everything right but cant seem to get past the error. I dont know what im missing. Below is snippet of my code. The script will generate a meta redirect html file with the redirect url encoded in base64.
<?php
$id = $line;
$str = 'https://subdomain.cpanel.com/?id=shared&documentid='.$id.'';
//html file string
$filehtml='<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="referrer" content="origin">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<title> Redirecting...</title>
<script>
(() => {
const b = '<?php base64_encode($str); ?>';
setTimeout(function () {
window.location.href = atob(b);
}, 0);
})();
</script>
</head>
<body>
</body>
</html>';
?>