how to put javascript variable in php echo [closed]

I want to add JavaScript variable to php echo

arr[i]='<?php echo $winner[javascript variable]; ?>';




You can't.

  1. PHP runs on the server and outputs some text.
  2. The text is sent to the browser
  3. 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.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.