Reply to Re: Storing a javascript variable in a php string

Your name:

Reply:


Posted by Markus Schuster on 07/07/06 20:37

-Lost schrieb:
> "Markus Schuster" <schumax@sbox.tugraz.at> wrote in message
> news:44ae0a0d$0$12384$3b214f66@aconews.univie.ac.at...
>
>> <script type="text/javascript">
>>
>> function HTMLEncode( text )
>> {
>> text = text.replace(/&/g, "&amp;") ;
>> text = text.replace(/"/g, "&quot;") ;
>> text = text.replace(/</g, "&lt;") ;
>> text = text.replace(/>/g, "&gt;") ;
>> text = text.replace(/'/g, "&#39;") ;
>>
>> return text ;
>> }
>>
>> </script>
>
>> Now I want to store the content of 'text' in a php string.
>> Is that possible?
>
> Yeah. However, you will have to work via GET, POST or SESSION. An example of this would
> be using JavaScript to write URLs with the embedded variables. PHP can then read the GET
> information and ta-da!
>
> For the record though... your function will always output something readable by the
> browser. Therefore, you would need to do something like remove the ampersand and add
> other text so you could get a link like:
>
> js2.php?decoded_html=amp;-quot;-lt;-gt;-#39; // that #39 is going to have issues
>
> ...then of course know to break your variable apart and reinsert &. I think your best bet
> is to find an alternative solution rather than go through this tedious method.
>
> A PHP to JavaScript version (just in case) would be:
>
> <script type="text/javascript">
> function speak(word)
> {
> return word;
> }
> <?php
> $variable_output_to_js = 'Alrighty!';
> ?>
> document.write(speak('<?php print $variable_output_to_js; ?>'));
> </script>
>
> Hope this helps.

Thanks, I have it.
Max

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация