首页 > 代码库 > 放假(六)
放假(六)
今天跑出去玩了,没怎么预习啊,就把基本数据类型看完了,做了一个进制转换的功能,就和那个计算器差不多的!
<!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> <?php $res = ""; $num = ‘‘; $kinds = ‘‘; if(!empty($_POST)){ $num = $_POST[‘num‘]; $kinds = $_POST[‘kinds‘]; switch ($kinds){ case "10to2": $res = decbin($num); break; case "10to8": $res = decoct($num); break; case "10to16": $res = dechex($num); break; case "2to10": $res = bindec($num); break; case "8to10": $res = octdec($num); break; default: $res = hexdec($num); } } ?> <form method="post"> 数:<input type="text" name="num" value="http://www.mamicode.com/<?php echo $num ?>"> <select name="kinds"> <option value="http://www.mamicode.com/10to2" <?php if($kinds == "10to2") echo "selected = selected"; ?> >10to2</option> <option value="http://www.mamicode.com/10to8" <?php if($kinds == "10to8") echo "selected = selected"; ?> >10to8</option> <option value="http://www.mamicode.com/10to16" <?php if($kinds == "10to16") echo "selected = selected"; ?> >10to16</option> <option value="http://www.mamicode.com/2to10" <?php if($kinds == "2to10") echo "selected = selected"; ?> >2to10</option> <option value="http://www.mamicode.com/8to10" <?php if($kinds == "8to10") echo "selected = selected"; ?>>8to10</option> <option value="http://www.mamicode.com/16to10" <?php if($kinds == "16to10") echo "selected = selected"; ?>>16to10</option> </select> <input type="submit" value="http://www.mamicode.com/转换"> <input type="text" value="http://www.mamicode.com/<?php echo $res; ?>"> </form> </body> </html>
放假(六)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。