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


Please Help Members By Posting Answers For Below Questions

What is Unobtrusive JavaScript & Why it's Important?

697


What is the requirement of debugging in javascript?

649


Do I need var in javascript?

669


List out the different ways an HTML element can be accessed in a Javascript code?

946


How javascript variables work?

638


How to find radio button selection when a form is submitted?

630


What is difference between callback and promise?

642


What is the microsoft version of javascript?

695


How to remove duplicate values from a javascript array?

699


Is python better than javascript?

608


What is the difference between undeclared & undefined?

697


How to handle exceptions in JavaScript?

683


How to change style on an element?

718


How to convert json object to string?

732


How do I add javascript to chrome?

686