[js] JS 與 PHP 傳值

Jacob Hsu
1 min readJul 3, 2018

--

javasript傳值給php

<script>
function express(){
var value="abc";
location.href="point.php?value=" +value;
}
</script>
<input type="button" value="button" onclick="express()">
<?php
echo $_GET['value'];
?>

php傳值給javascript

<?php
$value="abc";
?>

<script type="text/javascript">
var value="<?php echo $value; ?>";
document.write(value);
</script>

ref

--

--