I have seen plenty of things on the internet about how PHP variables can be turned into JavaScript ones simply by

```php
<?php

$var = "hello";

?>

<script>

var jsvar = "<?php echo $var; ?>";

alert(jsvar);

</script>

```

However it hasn't worked for me at all.

I've removed the quotes around the PHP as I thought that was the problem.

```js
var jsvar = <?php echo $var; ?>

```

However, it still doesn't alert the variable at all.

As some of the examples of this were around 4-8 years ago so I hope it has just changed, however, I'm sure I have made a mistake somewhere and would appreciate any help.

Any examples would be great.
Thanks in advance!