You cannot really use the setTimeout()
function as you suggest…
I guess this is roughly what you are looking for:
echo <<< EOT
<script type="text/javascript">
setTimeout(function() {
window.open('https://mywebsite/$link', '_blank');
}, 1000);
</script>
EOT;
Note: I just use the nowdoc
notation since it is easier to read. Certainly it is possible to use a normal literal string for the echo command too.
solved Why is set.timeout not working in this php while loop?