Passing PHP variables to Javascript

I had a simple problem. I wanted to pass a single variable from the PHP Server to some Javascript code.
In the top of my page I set the variable:
$myVar = $_SERVER['PHP_SELF'];
?>

Then I just call my php function and pass it that variable as an argument.
But…
I have to use PHP to echo back the value.
myJscriptFunction('<?php echo $myVar; ?>');

Book it!
  • Facebook
  • del.icio.us
  • Reddit
  • Technorati
  • StumbleUpon
  • Google Bookmarks
  • ThisNext

0 Responses to “Passing PHP variables to Javascript”


  • No Comments

Leave a Reply

You must login to post a comment.