How to access PHP variables in JQuery?
This article will give you an example of how to access php variable in jquery. I would like to share with you how to use php variable in jquery. This tutorial will give you a simple example of how to get php variable in jquery. I’m going to show you about how to print php variable in jquery.
If you are working on php and you need to print your php variable inside the jquery then you can simple get value. you can use "" for get value of php variable. in following example you can see :
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How to access PHP variables in JQuery?</title>
$simple = 'demo text string';
$myArray = array("One", "Two", "Three", "Four");
var simple ='<?php echo $simple; ?>';
var myArray = <?php echo json_encode($myArray); ?>;
I hope it can help you...
We are Recommending you
- Laravel Profile Image Upload Tutorial with Example
- Laravel TCPDF: Generate HTML to PDF File Example
- Laravel Carbon Count Days Between Two Dates Example
- Laravel Where Clause with Function Query Example
- How to Remove Numbers from String in PHP?
- How to Convert Camel Case to Snake Case in PHP?
- php array remove keys keep values example
- PHP - Getting Started PHPUnit test with simple example
- How to send mail using zoho smtp server in PHP Laravel?
- PHP - Capture screenshot of website from URL example
- PHP - How to implement Google new reCAPTCHA Code Example with Demo?
- How to remove duplicate values from Array in PHP?
- PHP Check Word Exist in String or Not Example
- How to Remove Null Values from Array in PHP?