Samet Kilictas’s Blog

Embed php into Javascript

by Samet Kilictas on Feb.24, 2009, under Jquery, PHP, Programming

In javascript you cannot read variables from a server instanly however if you embed your php code you may pass variables into javascript code.

So php can pass its variables when page loads. Here is an example using jquery

<?php $variable = 'Here is value'; ?>
<script type= "text/javascript">
$(document).ready(function(){
var button = <?php echo $variable; ?> ;
});
</script>

Keep Coding

VN:F [1.0.6_327]
Rating: 10.0/10 (1 vote cast)
:, , ,
No comments for this entry yet...

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...