how to put javascript variable in php echo

javascript, php

Solution

You can't.

- PHP runs on the server and outputs some text.

- The text is sent to the browser

- The browser interprets the text as HTML / JavaScript / etc

The PHP has finished running by the time the JavaScript is executed.

If you want to pass data back you need to make a new HTTP request and run a PHP script from scratch.

Problem

I want to add JavaScript variable to php echo ``` arr[i]='<?php echo $winner[javascript variable]; ?>'; ``` Thanks

Original source

Related problems