Archive for November, 2007

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!
  • del.icio.us
  • Technorati
  • ThisNext
  • Furl
  • blogmarks
  • Reddit
  • Digg
  • StumbleUpon