How can i print php variable in jquery?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this blog i will show you how to print php variable in jquery section. If we are working on php and we need to print our php variable inside the javascript then i hope we can simple get value. we can use “” for get the value of php variable. So now in the following example we can see :

Example:

<script type="text/javascript">
	var my_var = "<?php echo $my_variable; ?>";
	console.log(my_var);
</script>
OR
<script type="text/javascript">
	var my_var = <?php echo $my_variable; ?>;
	console.log(my_var);
</script>

Read Also : How to push item to 0 index or first of $scope object in AngularJS?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →