今天学习了一天的php和matlab
用php语言实现了html和php语言的交互
代码部分如下
<?php $values=''; if(!empty($_POST)) { $num = $_POST['num']; $zhuanhuan = $_POST['zhuanhuan']; if($zhuanhuan == 2) { $values = decbin($num); } else if($zhuanhuan == 8) { $values = decoct($num); } else { $values = dechex($num); } } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>转换进制</title> </head> <body> <form action="php-7.php" method="post"> 十进制:<input type="text" name="num"> 请输入要转换的进制:<select name="zhuanhuan" id=""> <option value="2">二进制</option> <option value="8">八进制</option> <option value="16">十六进制</option> </select><input type="submit" value="转换"> <input type="text" name="" id="" value="<?php echo $values;?>"><br> </form> </body> </html>
可以实现十进制转换成二进制,八进制,十六进制的页面