>>571 汚くても良ければ。
<?PHP
$msg = 'test';

echo <<<EOD
<script type="text/javascript">
<!--
function MyAlert(msg)
{
alert(msg);
}
//-->
</script>
<input type="button" value="click me" onclick="MyAlert('{$msg}');">
EOD;
?>