Using PHP inside of HTML to redirect to a random site <p>I need to be able to have the user click a button, and be redirected to a random page.</p> <p>I tried putting the PHP inside of JavaScript, and that inside of HTML, like this:</p> <pre><code>&lt;script&gt; &lt;button onclick="var jsVar = "&lt;?php $urls = array("www.site1.com", "www.site2.com", "www.site3.com","www.site4.com"); $url = $urls[array_rand($urls)]; header("Location: http://$url"); ?&gt;""&gt;Click&lt;/button&gt; &lt;/script&gt; </code></pre> <p>I know this may have many errors, and help is very appreciated. Thank you!</p>