简体   繁体   English

如何将 span id 值存储到 PHP 变量中

[英]How to store span id value in to PHP variable

I want to know how to store span/div id value in to PHP variable....in id=event_id there is value like '234'... so i want store that value in to php variable我想知道如何将 span/div id 值存储到 PHP 变量中……在 id=event_id 中有像“234”这样的值……所以我想将该值存储到 php 变量中

  <?php
 //This Statement stores data in variable
 $test = '<span id ="event_id" ></span>'; 
 //this is for printing variable that contains data
 echo $test;
?>

<script>
 function setEventId(event_id){
  document.querySelector('#event_id')= event_id;
 }
 </script>

If I understood your question correctly, you want to do something like this:如果我正确理解了你的问题,你想做这样的事情:

<?php
 //This Statement stores data in variable 
 $test = '<span id ="event_id" ></span>';
 //this is for printing variable that contains data
 echo $test;
 $event_id = "<script>document.writeln(document.getElementById('event_id').innerHTML)</script>";
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM