When I have to write large html or js in PHP, I like to use Heredoc syntax
$variable = <<<EOT
<script>
$(document).ready(function(){
//your stuff
});
</script>
EOT;
Read the reference http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Note in the manual
It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including Mac OS X. The closing delimiter must also be followed by a newline.
If this rule is broken and the closing identifier is not "clean", it will not be considered a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found before the end of the current file, a parse error will result at the last line.
Heredocs can not be used for initializing class properties. Since PHP 5.3, this limitation is valid only for heredocs containing variables.
UPDATE
Based on the OP comment
<?php
$data = 'test';
$variable = <<<EOT
<script>
$(document).ready(function(){
alert('$data');
});
</script>
EOT;
?>
<html>
<head>
<title><?php echo $data; ?></title>
<?php echo $variable; ?>
</head>
<body>
<div><?php echo "The alert showed $data";?></div>
<body>
</html>