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

What is the default scope in javascript?

0 Answers  


Where do you put javascript in html?

0 Answers  


How do you define a class and its constructor?

0 Answers  


How to port a GUI application onto Web

0 Answers   TCS,


What does unshift() function do in Javascript?

0 Answers  






What is the difference between undefined and object?

0 Answers  


How to select an element by id and swapping an image?

0 Answers  


What do “1”+2+4 evaluate to?

0 Answers  


Is a relation always a function?

0 Answers  


What is the result of below given line of code in java script? 5+4+'7'?

0 Answers  


print the following using loop. 54321 4321 321 21 1

2 Answers   Delhi Public School,


When would you use var in your declaration and when you wouldn’t?

0 Answers  


Categories