Javascript Alert不会提醒字符串?

I'm a bit confused and i'm guessing there's a simple fix so please help.

I have this code (Just a snippet)

$new = "1";

<script language="javascript">
    alert(<?php echo $new; ?>);
</script>

This works fine. It will alert "1". However, if I change $new to

$new = "Hello";

It no longer alerts the value? Any ideas?

You're not quoting your string within the Alert function.

Do this:

alert('<?php echo $new;?>');

or this, for short

alert('<?= $new ?>');

You need put to quotes around text in alert to alert a String.

<script language="javascript">
    alert('<?php echo $new; ?>');
</script>

Reason why "1" gets alerted is because, it is considered as an integer and that doesn't require quotes around it.