lines = array(); } function write($str) { $str = preg_replace("/[\n\r]+/", " ", $str); $str = preg_replace("/\'/", "\\\' ", $str); $this->lines[] = $str; } function flush () { $ret_str = ""; $ret_str .= "function jsprint() {\n"; $ret_str .= "var s = '';\n"; foreach ($this->lines as $line) { $ret_str .= "s += '$line';\n"; } $ret_str .= "return (s);\n}\n\n"; $ret_str .= "document.write(jsprint());\n"; return $ret_str; } function mklink ($link, $title) { return "" . $title . ""; } } # test it: function testIt (){ $js = new jsprint(); $js->write("Hello, Charlie\nAre you well?\nAnswer me, you Dolt!"); $js->write("Hello, Marie\nAre you OK?\nWhat's up, you Dolt!"); $js->write("Hello, Henry\nAre you well?\nWrite someting, you Dolt!"); $js->flush(); } ?>