2010年1月26日星期二

Re: [fw-mvc] javascript encode php

Roozbeh, please use reply-all :)

What I meant by using a text area is that FCKEditor can replace a textarea with a WYSIWYG editor. It will automatically pull in the value of the textarea and you won't have to do any special escaping (besides htmlentities, or $this->escape()). This also allows non-JS browsers to use your form (if that's a concern for you).

--
Hector


On Tue, Jan 26, 2010 at 4:53 PM, Roozbeh Matloobi <roozbeh.matloobi@globalphotobooks.com> wrote:
Thanks for your comment Hectore but JSON didnt work and i definitly need FCKEditor's and canot replace it with textarea.

Hector Virgen wrote:
It would be easier to place it in a <textarea> element and use FCKEditor's "replace textarea" ability.

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 <mailto: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
         



没有评论: