0

I am working on one PHP file (index.php) ,and i am trying to convert a javascript variable to PHP variable ,and i can not find a way , please Help : This is my code on index.php :

<script>
var name="James";
</script>
<?php
echo 'Hello',' ',name;
?>

Thanks

1 Answers1

1

This is not possible in the manner you are attempting. PHP is server side and JS is client side. The two have no direct means of communication as they are executed in completely different places.

If you need to send the name JS variable to your PHP page, you would nee to use AJAX.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339