Is it possible to assign a php variable to javascript ? And
also is it possible to fetch the page contents if the url
is not under our control ?
Answer Posted / gagan rana
Yes ,it is possible by doing like the following:
<?php
$x = 'hai!';
echo "<script>var x = '" . $x . "';</script>";
?>
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is Unobtrusive JavaScript & Why it's Important?
What is the requirement of debugging in javascript?
Do I need var in javascript?
List out the different ways an HTML element can be accessed in a Javascript code?
How javascript variables work?
How to find radio button selection when a form is submitted?
What is difference between callback and promise?
What is the microsoft version of javascript?
How to remove duplicate values from a javascript array?
Is python better than javascript?
What is the difference between undeclared & undefined?
How to handle exceptions in JavaScript?
How to change style on an element?
How to convert json object to string?
How do I add javascript to chrome?