Alex Mcauley wrote:
> global how .. that doesnt really explain much
> 
> 
> If you mean globaly accessible to javascript then you need to do something 
> like
> 
> <?php
> $bar='bar';
> echo("<script>foo=$bar</script>");
> 
> ?>
> ....


marioosh, you also need to properly quote strings, or convert php 
variables to javascript notation.

Easiest way to do this is to use json_encode() function:

<?php
$bar='bar';
echo ("<script>foo=" . json_encode($bar) . "</script>");
?>

Which will give you something like:
<script>foo="bar"</script>

If $bar was an array, eg $bar=array('one','two'), the json_encode 
function would also convert it to javascript notation:
["one", "two"];

Regards,
SWilk

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to