What is the difference between PHP running on the web server and JavaScript running in the browser?

PHP runs on the web server, meaning the server processes the PHP code and sends the output (usually HTML) to the client's browser. On the other hand, JavaScript runs in the client's browser, allowing for dynamic interactions and modifications to the webpage without needing to reload the entire page. PHP is typically used for server-side tasks like database operations and form processing, while JavaScript is used for client-side tasks like form validation and animations.

<?php
// PHP code example
$name = "John";
echo "Hello, $name!";
?>