How can PHP code be modified to output JavaScript code instead?

To output JavaScript code from PHP, you can use the `echo` or `print` functions to directly output JavaScript code within the PHP script. This allows you to dynamically generate JavaScript code based on PHP variables or conditions. By embedding JavaScript within PHP, you can seamlessly integrate server-side logic with client-side functionality.

<?php
// PHP code that generates JavaScript code
$variable = "Hello, World!";
echo "<script>";
echo "var message = '$variable';";
echo "console.log(message);";
echo "</script>";
?>