You've already opened php with <?php
and already invoked the echo
call.
It is best to concatenate the variable by closing the quotes and using a period:
echo "<script language='javascript'>
document.write('". $v ."');
</script>";
Like Mr.Alien said in the comments, it doesn't appear you need to echo the Javascript. You can just invoke PHP where you need to echo the variable. If your install supports short tags, you can do this:
<body>
<script language='javascript'>
document.write('<?= $v ?>');
</script>
</body>
<?= $v ?>
is a short tag for <?php echo $v; ?>