|
Posted by -Lost on 07/07/06 10:18
"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, "&") ;
> text = text.replace(/"/g, """) ;
> text = text.replace(/</g, "<") ;
> text = text.replace(/>/g, ">") ;
> text = text.replace(/'/g, "'") ;
>
> 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.
-Lost
[Back to original message]
|