<?php $str = "O'Reilly?"; eval("echo '" . addslashes($str) . "';"); ?>
str = str.replace(/'/g, "\\'");