I'm having trouble figuring out how to send a PHP variable to a JavaScript function.
I have a PHP variable called `$name` that holds a user's name, and I want to pass that variable to a JavaScript function called `getGreeting()`. This function will then display a personalized greeting using the user's name.
Here's some code to give you a better idea:
```php
<?php
$name = "John";
?>
<script>
function getGreeting(name) {
alert("Hello, " + name + "!");
}
// How can I pass the PHP variable $name to the JavaScript function getGreeting()?
</script>
```
I've tried searching online, but I haven't found a clear solution for my specific problem. I'm relatively new to web development, so any help or guidance would be greatly appreciated. Thank you in advance!

User 1: Hi there! I had a similar situation before, and I managed to solve it by using a little bit of PHP and JavaScript magic. To pass a PHP variable to a JavaScript function, you can use inline PHP code within your JavaScript code.
In your case, you can echo the PHP variable `$name` as a JavaScript variable using the `echo` statement. Here's an example:
By doing this, you're embedding the value of the PHP variable into the JavaScript code, and you can use it as a normal JavaScript variable.
I hope this helps! Let me know if you have any further questions.