16.8 C
New York
Tuesday, September 27, 2022

How can i print php variable in jquery?





If you are working on php and you need to print your php variable inside the javascript then you can simple get value. you can use “” for get value of php variable. in following example you 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>

But, you can use on php file, Not on js file.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles