-- Mon
On Wed, Jan 27, 2010 at 3:04 PM, kirpit <kirpit@gmail.com> wrote:
Hi,There is json_encode and json_decode which converts php vars to javascript json type and reverse. The basic logic is like;// JavaScriptvar jsonString = '<?php echo json_encode($phpVar); ?>';var jsObject = eval( "(" + jsonString + ")" );Remember, you should eval json string on javascript side to get js object and there are some security issues about that:Good luck.2010/1/27 Roozbeh Matloobi <roozbeh.matloobi@globalphotobooks.com>
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
没有评论:
发表评论