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

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.