How has the perception and usage of JavaScript evolved in the past decade, especially in relation to PHP development?

Over the past decade, JavaScript has evolved from being primarily used for client-side scripting to becoming a versatile language for both front-end and back-end development. This shift has led to an increase in the usage of JavaScript frameworks and libraries like Node.js for server-side development. In comparison, PHP has remained a popular choice for server-side scripting, but its usage has somewhat declined in favor of JavaScript for full-stack development.

// PHP code snippet implementing a fix for using JavaScript alongside PHP

<!DOCTYPE html>
<html>
<head>
    <title>JavaScript and PHP</title>
</head>
<body>
    <h1 id="demo">Hello, World!</h1>

    <?php
    $message = "Hello from PHP!";
    echo "<script>document.getElementById('demo').innerHTML = '$message';</script>";
    ?>
</body>
</html>