本文整理汇总了PHP中Calculator::division方法的典型用法代码示例。如果您正苦于以下问题:PHP Calculator::division方法的具体用法?PHP Calculator::division怎么用?PHP Calculator::division使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Calculator
的用法示例。
在下文中一共展示了Calculator::division方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Calculator
$obj = new Calculator();
if (isset($_POST['btn'])) {
$first_number = $_POST['first_number'];
$last_number = $_POST['last_number'];
$btn = $_POST['btn'];
if ($btn == '+') {
$result = $obj->addition($first_number, $last_number);
} else {
if ($btn == '-') {
$result = $obj->subtraction($first_number, $last_number);
} else {
if ($btn == '*') {
$result = $obj->multiplication($first_number, $last_number);
} else {
if ($btn == '/') {
$result = $obj->division($first_number, $last_number);
} else {
if ($btn == '%') {
$result = $obj->reminder($first_number, $last_number);
}
}
}
}
}
}
?>
<html>
<head>
<title>PHP OOP Calculator</title>
</head>
<body>
示例2: Calculator
<?php
$obj = new Calculator();
if (isset($_POST['btn'])) {
$first_number = $_POST['first_number'];
$second_number = $_POST['second_number'];
if ($_POST['btn'] == '+') {
$result = $obj->addition($first_number, $second_number);
}
if ($_POST['btn'] == '-') {
$result = $obj->subtraction($first_number, $second_number);
}
if ($_POST['btn'] == '*') {
$result = $obj->multiply($first_number, $second_number);
}
if ($_POST['btn'] == '/') {
$result = $obj->division($first_number, $second_number);
}
// if($first_number==0 or $second_number==0){
// $result= $obj->nothing();
// }
}
?>
<tr>
<td><?php
echo $result['label_value'];
?>
</td>
<td>
<?php
echo $result['value'];