在具有多个值的 PHP 函数中传递 ID


Passing ID in PHP function which has multiple value

$id=$_GET['id']; // this result has values like `1,2,3..multiple`

我用它来传递 PHP 代码中的函数some($id);

In JS file: 
fucntion some(cid){
 // I have check it with alert(cid);
}

但它在这里只接受或持有一个值。为什么会这样?

请帮忙。我希望所有ids都位于单个值中(即,假设有1,2,3,4,那么它们都应该在cid中(。

希望你想要这样:

<?php 
$id=$_GET['id'];
?> 
<script>
var cid = "<?php echo $id;?>"; //pass php value in js
fucntion some(cid){
 // I have check it with alert(cid);
}
some(cid); //calling 
</script>

如果我没猜错,你的请求中有多个id(复选框?尝试将表单输入命名为不是id而是id[]$_GET["id"]应该给你一个数组。