Php small function details

Source: Internet
Author: User

<? Php
$ Dy = $ _ POST ["dy"];
$ De = $ _ POST ["de"];
$ Jsf = $ _ POST ["select"];
$ Qingkong = $ _ POST ["qingkong"];
$ Submit = $ _ POST ["Submit"];

If ($ jsf = "jia "){
$ Zhi = $ dy + $ de;
$ Zhi = "Your calculation result is: $ zhi ";
}
If ($ jsf = "jian "){
$ Zhi = $ dy-$ de;
$ Zhi = "Your calculation result is: $ zhi ";
}
If ($ jsf = "chen "){
$ Zhi = $ dy * $ de;
$ Zhi = "Your calculation result is: $ zhi ";
}
If ($ jsf = "chu "){
If ($ de = "0 "){
$ Zhi = "the divisor cannot be 0. enter a valid number! ";
} Else {
$ Zhi = $ dy/$ de;
$ Zhi = "Your calculation result is: $ zhi ";
}
}
If ($ jsf = "yu "){
If ($ de = "0 "){
$ Zhi = "the remainder cannot be 0 ";
} Else {
$ Zhi = $ dy % $ de;
}
}

If ($ qingkong = "empty "){
Unset ($ dy, $ de, $ zhi );
}

?>

<Html>
<Head> <title> counter </title> <Body>
<Form method = "post" action = "">
<Table border = "1">
<Caption align = "center"> simple calculator </caption>
<Tr>
<Td height = "75">
<Input type = "text" value = "<? Php echo $ dy;?> "Name =" dy "/>
</Td>
<Td>
<Select name = "select">
<Option value = "jia"> + </option>
<Option value = "jian">-</option>
<Option value = "chen"> * </option>
<Option value = "chu">/</option>
<Option value = "yu" >%</option>
</Select>
</Td>
<Td>
<Input type = "text" value = "<? Php echo $ de;?> "Name =" de "/>
</Td>
<Td>
<Input type = "submit" name = "Submit" value = "submit"/>
<Input type = "submit" name = "qingkong" value = "empty"/>
</Td>
</Tr>
<Tr>
<Td height = "23" colspan = "4"> <? Php echo $ zhi;?> </Td>
</Tr>
</Table>
</Form>
</Body>
</Html>



From battlefield diaries _ LAMP brothers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.