Home  >  Article  >  Backend Development  >  How to pass JavaScript variables to PHP?

How to pass JavaScript variables to PHP?

WBOY
WBOYforward
2023-08-26 23:45:061586browse

How to pass JavaScript variables to PHP?

You can easily get JavaScript variable values ​​on the same page in PHP. Please try the following code:

<script>
   var res = "success";
</script>
<?php
   echo "<script>document.writeln(res);</script>";
?>

The above is the detailed content of How to pass JavaScript variables to PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete