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 ?



Is it possible to assign a php variable to javascript ? And also is it possible to fetch the page ..

Answer / 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

More JavaScript Interview Questions

How do I use javascript to password-protect my web site?

0 Answers  


How to create objects in JavaScript?

0 Answers  


What is the instanceof operator in JavaScript?

0 Answers  


Difference between undefined and undeclared variables?

0 Answers  


What is event bubbling and capturing in javascript?

0 Answers  






What is the statement to enable strict mode in javascript quiz?

0 Answers  


Is JavaScript a case-sensitive language?

0 Answers  


What is the default scope in javascript?

0 Answers  


Is a relation always a function?

0 Answers  


Why is javascript not oop?

0 Answers  


What is decodeuri(), encodeuri() in javascript?

0 Answers  


Where should I put script tags?

0 Answers  


Categories