Coding & Programming > JavaScript Forum

how to php variable value assign as java script

(1/1)

Hi-Tech ITO:


<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'].

Navigation

[0] Message Index

Go to full version