Home >php教程 >php手册 >简单的计算功能

简单的计算功能

WBOY
WBOYOriginal
2016-05-25 18:02:52835browse

效果图

要做出上面的效果图,我们需要对隐藏表单的元素有个简单的了解

隐藏表单的元素的语法格式为:,其功能是在浏览网页时使浏览器不显示这个表单字段元素,但在提交表单时将这个隐藏表单元素的name属性

和value属性值发送给服务器

<span style="color: #000000;">php
    </span><span style="color: #800080;">$CFQ</span> = <span style="color: #800080;">$_POST</span>["tag"];<span style="color: #008000;">//</span><span style="color: #008000;">判断用户是否单击了计算按钮</span>
    <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$CFQ</span> == 1<span style="color: #000000;">)
    {
        </span><span style="color: #800080;">$addnum1</span> = <span style="color: #800080;">$_POST</span>["addnum1"];<span style="color: #008000;">//</span><span style="color: #008000;">通过$_POST内置数组获取加数</span>
        <span style="color: #800080;">$addnum2</span> = <span style="color: #800080;">$_POST</span>["addnum2"<span style="color: #000000;">];
    }
    </span><span style="color: #0000ff;">else</span><span style="color: #000000;">{
        </span><span style="color: #800080;">$addnum1</span> = <span style="color: #800080;">$addnum2</span> = 0<span style="color: #000000;">;        
    }
    </span><span style="color: #800080;">$sum</span> = <span style="color: #800080;">$addnum1</span> + <span style="color: #800080;">$addnum2</span><span style="color: #000000;">;
</span>?><span style="color: #000000;">
在表单中输入两个整数
</span>
$addnum1;?>"> + $addnum2;?>"> = echo $sum;?>

 

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