<?php
$myPhpVar = '"Hello again! This is how we" . "\
" . "add line breaks to an alert box!"';
?>
<script type="text/javascript">
alert("<?php echo $myPhpVar; ?>");
</script>
Why are you generating alerts from PHP when the only purpose for alerts in the 21st Century is for debuggung JavaScript (which is why some languages include an option in alerts for either turning off further alerts or disabling Javascript for the page).