<?php
if(!empty($_POST))
{
    $m=0;
    for($i=0;$i<sizeof($_POST['p']);++$i)
    {
        $m |= $_POST['p'][$i];
    }
}
?>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
 
<head>
  
<title> 与运算符和或运算符(&和|) </title>
  
<meta name="Author" content="Libch">
  
<meta name="Keywords" content="">
  
<meta name="Description" content="">
  
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  
<link href="" rel="stylesheet" type="text/css" />
  
<script language="javascript">

  
</script>
 
</head>
 
<body>
 
<form name="form" method="POST" action="andmark.php">
    
<input type="checkbox" name="p[]" value="2" <?php if($m & 2) echo "checked";?>>选择1<br>
    
<input type="checkbox" name="p[]" value="4" <?php if($m & 4) echo "checked";?>>选择2<br>
    
<input type="checkbox" name="p[]" value="8" <?php if($m & 8) echo "checked";?>>选择3<br>
    
<input type="submit" value="Click">
  
</form>
 
</body>
</html>

相关文章:

  • 2021-07-25
  • 2021-12-03
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
相关资源
相似解决方案