how to php variable value assign as java script

Author Topic: how to php variable value assign as java script  (Read 3443 times)

Offline Hi-Tech ITOTopic starter

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 10
  • Karma: 0
  • Gender: Male
how to php variable value assign as java script
« on: 04-22-2013, 22:55:07 »


<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


Offline Shikha Singh

  • Trade Count: (0)
  • Sr. Member
  • ****
  • Thank You 52
  • Posts: 323
  • Karma: 0
  • Gender: Female
  • solution to start online business
    • solution to start online business
Re: how to php variable value assign as java script
« Reply #1 on: 02-23-2016, 00:47:40 »
<?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>

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
3398 Views
Last post 09-19-2016, 02:33:34
by rajeshmehra615
1 Replies
2769 Views
Last post 10-26-2017, 00:28:00
by damponting44
0 Replies
3064 Views
Last post 11-04-2011, 00:33:08
by mack0
3 Replies
3870 Views
Last post 08-19-2015, 01:48:54
by SanviMalhotra
0 Replies
724 Views
Last post 05-04-2016, 08:27:34
by Akash Varma