What is the correct syntax for passing PHP variables to JavaScript variables for use in alerts?

When passing PHP variables to JavaScript variables for use in alerts, you need to echo the PHP variable within a set of script tags in your PHP code. This way, the PHP variable value will be assigned to the JavaScript variable when the page is loaded. You can then use the JavaScript variable in your alert function to display the PHP variable value in an alert box.

<?php
$php_variable = "Hello, World!";
echo "<script>var js_variable = '" . $php_variable . "';</script>";
?>
<script>
alert(js_variable);
</script>