사용자 도구

사이트 도구


playground:start
[공지]회원 가입 방법
[공지]글 작성 및 수정 방법

문서의 이전 판입니다!


연습장

<php> <!DOCTYPE HTML PUBLIC “-W3CDTD HTML 4.01 TransitionalEN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <title>The Calculator</title> <meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”> <style type=“text/css”> body {font-family: Verdana, Arial; font-size: 12px;} h1 {font-family: Verdana, Arial; font-size: 24px;} h2 {font-family: Verdana, Arial; font-size: 18px;} h3 {font-family: Verdana, Arial; font-size: 14px; font-weight: bold;} </style> </head> <body> <h1>The Calculator</h1> <h3>Version 1.2</h3> <p>Important: Use the radian equivalent to the number when getting cos, sin and tan.<br> Use the period character as a comma.<br> Good: <font color=“green”>50.36</font><br> Bad: <font color=“red”>50,36</font></p> <hr> <h2>Simple</h2> <form action=“<?php $PHP_SELF ?>” method=“post”> <input name=“first” type=“text” size=“6” maxlength=“10”> <select name=“method1”> <option value=“add” selected>Add</option> <option value=“sub”>Subtract</option> <option value=“multi”>Multiply</option> <option value=“div”>Divide</option> </select> <input name=“second” type=“text” size=“6” maxlength=“10”> <br><br> <input name=“submit1” type=“submit” value=“Calculate”> </form> <?php Simple if ($submit1 == true) {

if ($method1 == "add") {$ans = $first + $second;}
else if ($method1 == "sub") {$ans = $first - $second;}
else if ($method1 == "multi") {$ans = $first * $second;}
else if ($method1 == "div") {$ans = $first / $second;}

$ans = number_format($ans, 2, ',', ' '); echo “<p>The answer is $ans</p>”; } ?> <hr> <h2>Advanced</h2> <form action=“<?php $PHP_SELF ?>” method=“post”> <input name=“number” type=“text” size=“6” maxlength=“10”> <select name=“method2”>

<option value="cos">Get cosine</option>
<option value="sin">Get sine</option>
<option value="tan">Get tangent</option>
<option value="decbin">Decimal to binary</option>
<option value="bindec">Binary to decimal</option>
<option value="dechex">Decimal to hexadecimal</option>
<option value="hexdec">Hexadecimal to decimal</option>
<option value="deg2rad">Degree to radian</option>
<option value="rad2deg">Radian to degree</option>

</select> <br> <br> <input name=“submit2” type=“submit” value=“Calculate”> </form> <?php Advanced if ($submit2 == true) { if ($method2 == “cos”) {$ans = cos($number);} else if ($method2 == “sin”) {$ans = sin($number);} else if ($method2 == “tan”) {$ans = tan($number);} else if ($method2 == “decbin”) {$ans = decbin($number);} else if ($method2 == “bindec”) {$ans = bindec($number);} else if ($method2 == “dechex”) {$ans = dechex($number);} else if ($method2 == “hexdec”) {$ans = hexdec($number);} else if ($method2 == “deg2rad”) {$ans = deg2rad($number);} else if ($method2 == “rad2deg”) {$ans = rad2deg($number);} echo “<p>The answer is $ans</p>”; } ?> </body> </html> </php>

로그인하면 댓글을 남길 수 있습니다.
검색
[홈레코딩 필독서]"모두의 홈레코딩"구매링크


playground/start.1643431976.txt.gz · 마지막으로 수정됨: 2022/01/29 저자 정승환