<?php $str_php = "Lorem Ipsum" ?>
<script language="javascript">
var str_js = <?= $str_php ?>;
alert (str_js);
</script>
<?php $str_php = "Lorem Ipsum" ?>
<script language="javascript">
var str_js = '<?= $str_php ?>'; //! Добавить кавычки
alert (str_js);
</script>