public function escJsStr($str) { return '\'' . str_replace(array("'", "\n"), array("\\'", "\\n"), $str) . '\''; }