Or you can try encoding it to JSON (not tested):
<script type="text/javascript">
var content = <?php echo json_encode($string); ?>;
</script>
--
Hector
On Tue, Jan 26, 2010 at 3:39 PM, Roozbeh Matloobi <roozbeh.matloobi@globalphotobooks.com> wrote:
Hi All,
I try to display a php variable(include string, integer and \ / ( ) ,... ) into javascrip and dispaly through a text editore called FCKEditor. but i faced but few bugs.
I tried to handel the bugs by using
$content = str_replace(array("\r", "\n", "\t"), '', $content);
$content = str_replace("'", "\'", $content);
$content = str_replace("", "\\", $content);
by using above function I am able to fix the bugs related to \ , \n however still some bugs left for other character like "(".
is there any solution general javascript encode php?
My appricate for any help
Thanks,
Roozbeh
没有评论:
发表评论