how to php variable value assign as java script

Started by Hi-Tech ITO, 04-22-2013, 22:55:07

Previous topic - Next topic

Hi-Tech ITOTopic starter



<script>
var id=`$`php;
</script>

i have add php variable store as JavaScript. but some thing wrong in my code. what wrong with there please help me
  •  


Shikha Singh

<?php
//somewhere set a value
$var = "a value";
?>

<script>
// then echo it into the js/html stream
// and assign to a js variable
spge = '<?php echo $var ;?>';

// then
alert(spge);

</script>


Lishmalinyjames

I guess you can use cookies for it.
First add a cookie jquery plugin.
Then store that window width in a cookie variable.
Access your cookie in PHP like $_COOKIE['variable name'].