简体   繁体   中英

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

  <?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>";
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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