Home >Backend Development >PHP Tutorial >求一段用php代码,该怎么解决

求一段用php代码,该怎么解决

WBOY
WBOYOriginal
2016-06-13 10:38:09825browse

求一段用php代码
求一段用php代码,网页上有个输入框,输入半径之后,点击按钮求圆的面积

------解决方案--------------------

PHP code
<?php echo "<input type='text' id='round' value=''/>";    echo "<input type="button" id="submit" value="Submit" onclick="javascript:getArea()">";    echo "<p id="area"></p>";?>    <script>    var round;    var area;    var PI = 3.14;    function getArea()    {        round = parseFloat(document.getElementById("round").value);        area = 4/3*PI*round*round;        setArea(area);    }    function setArea(area)    {        document.getElementById("area").innerHTML = "The Round's Area is : "+area ;    }</script><br><font color="#e78608">------解决方案--------------------</font><br>
PHP code
$area = 0;if(isset($_GET['r'])) $area = pi()*$_GET['r']*$_GET['r'];echo 半径<input type="text" name="r"><input type="submit" value="计算">面积=$areaHTML;<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:dedecms栏目伪静态规则Next article:kindeditor有关问题