ваый,
 Может не строку, а массив переделывать в json ?
header('Content-type:text/html; charset=utf-8');
$str= array('hello');
$json=json_encode($str);
<html>
  <head>
    <script>
      str=eval(<?=$json?>)
      function func(str)
      {
        alert(str[0])
      }
    </script>
  </head>
  <body onload="func(str);">
  </body>
</html>