function skill($id) { if ($division != 0) { $division = 100 * (7 - division($id)) / 7; } else { $division = 1; } $skill = $division; //*($rating)*($adminMark)*(kdr($kills,$assists,$deaths))*gWonRatio($won,$lost); return intval($skill); }
function origenCheck($valor1, $valor2) { $cadena = ""; if (isset($_POST["chkSuma"])) { $cadena .= $_POST["chkSuma"] . ": " . suma($valor1, $valor2) . "<br />"; } if (isset($_POST["chkResta"])) { $cadena .= $_POST["chkResta"] . ": " . resta($valor1, $valor2) . "<br />"; } if (isset($_POST["chkMultiplicacion"])) { $cadena .= $_POST["chkMultiplicacion"] . ": " . multiplicacion($valor1, $valor2) . "<br />"; } if (isset($_POST["chkDivision"])) { $cadena .= $_POST["chkDivision"] . ": " . division($valor1, $valor2) . "<br />"; } return $cadena; }
<?php $valor1 = $_POST["txtValor1"]; $valor2 = $_POST["txtValor2"]; $cadena = ""; if (!isset($_POST["suma"])) { $cadena = $_POST["suma"] . ": " . suma($valor1, $valor2) . "<br />"; } if (!isset($_POST["resta"])) { $cadena = $_POST["resta"] . ": " . resta($valor1, $valor2) . "<br />"; } if (!isset($_POST["multiplicacion"])) { $cadena = $_POST["multiplicacion"] . ": " . multiplicacion($valor1, $valor2) . "<br />"; } if (!isset($_POST["division"])) { $cadena = $_POST["division"] . ": " . division($valor1, $valor2) . "<br />"; } function suma($val1, $val2) { $resultado = $val1 + $val2; return $resultado; } function resta($val1, $val2) { $resultado = $val1 - $val2; return $resultado; } function multiplicacion($val1, $val2) { $resultado = $val1 * $val2; return $resultado; }
} // 引数のどちらかまたは両方が数字でなければExceptionを投げる if (!is_numeric($devidend) || is_numeric($divisor)) { throw new Exception('文字列を処理することはできません。'); } // 除算の結果を返す return $dividend / $divisor; } // 除算を連続して行うため、で0田を配列にセットする $array = array(array('dividend' => 10, 'divisor' => 2), array('dividend' => null, 'divisor' => 2), array('dividend' => 10, 'divisor' => 0), array('dividend' => 'ten', 'divisor' => 'two')); foreach ($array as $dat) { echo '<p>'; echo $dat['dividend'] . ' を ' . $dat['divisor'] . ' で割ろうとすると:<br>'; try { // 除算を行います。渡す引数によっては例外が発生する。 $result = division($data['dividend'], $dat['divisor']); echo '結果は ' . $result . ' です'; } catch (NullDataException $e) { // NullDataExceptionが投げられた場合の例外処理を行う。 echo '当然ですが、' . $e->getMessage(); } catch (ZeroDivisionException $e) { // ZeroDivisionExceptionが投げられた場合の例外処理を行う。 echo '値が不定となるため、' . $e->getMessage(); } catch (Exception $e) { // その他の例外が投げられた場合の例外処理を行う。 echo '残念ですが、' . $e->getMessage(); } echo '</p>'; } ?> </div>
function moyenne($values) { return division(somme($values), count($values)); }
} try { echo '1/2 = ' . division(1, 2); } catch (OcarinaException $e) { echo '1/2 = ' . $e->getError(); } echo '<br />'; try { echo '2/1 = ' . division(2, 1); } catch (OcarinaException $e) { echo '2/1 = ' . $e->getError(); } echo '<br />'; try { echo '1/0 = ' . division(1, 0); } catch (OcarinaException $e) { echo '1/0 = ' . $e->getError(); } echo '<br />'; try { echo '0/1 = ' . division(0, 1); } catch (OcarinaException $e) { echo '0/1 = ' . $e->getError(); } echo '<br />'; try { echo '1/lol = ' . division(1, 'lol'); } catch (OcarinaException $e) { echo '1/lol = ' . $e->getError(); } echo '<br />';
<?php $valor1 = $_POST["txtValor1"]; $valor2 = $_POST["txtValor2"]; $cadena = ""; if (isset($_POST["chkSuma"])) { $cadena .= $_POST["chkSuma"] . ": " . suma($valor1, $valor2) . "<br />"; } if (isset($_POST["chkResta"])) { $cadena .= $_POST["chkResta"] . ": " . resta($valor1, $valor2) . "<br />"; } if (isset($_POST["chkMultiplicacion"])) { $cadena .= $_POST["chkMultiplicacion"] . ": " . multiplicacion($valor1, $valor2) . "<br />"; } if (isset($_POST["chkDivision"])) { $cadena .= $_POST["chkDivision"] . ": " . division($valor1, $valor2) . "<br />"; } echo $cadena; function suma($val1, $val2) { $resultado = $val1 + $val2; return $resultado; } function resta($val1, $val2) { $resultado = $val1 - $val2; return $resultado; } function multiplicacion($val1, $val2) { $resultado = $val1 * $val2;
function modify($myDir, $myFile) { global $factor; $myContent = fopen($myDir . "/" . $myFile, "r") or die("Datei " . $myDir . " / " . $myFile . " konnte nicht zum Lesen ge�ffnet werden!"); $myNewContent = fopen($myDir . "/" . str_replace(".", "_" . $factor . ".", $myFile), "w") or die("Datei " . $myDir . " / " . str_replace(".", "_" . $factor . ".", $myFile) . " konnte nicht zum Schreiben ge�ffnet werden!"); fputs($myNewContent, "#Modified by MapbenderTools" . "Date: " . date("d.m.Y") . "Factor: " . $factor . "\n\n"); //fputs($myNewContent, "#Date: ". date("d.m.Y") . "Factor: ". $factor . "\n\n"); //fputs($myNewContent, "#Factor: ". $factor . "\n\n"); while (!feof($myContent)) { $myLine = fgets($myContent, 1024); if (preg_match("/\\bSIZE\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], multiplicate($matches[1]), $myLine)); } } else { if (preg_match("/(.*OFFSET)\\s*(\\d+.?\\d*)(\\s*)(\\d+.?\\d*)(\\s*)/i", $myLine, $matches)) { $myNewOFFSET = $matches[1] . " " . multiplicate($matches[2]) . " " . multiplicate($matches[4]) . $matches[5]; fputs($myNewContent, $myNewOFFSET); } else { if (preg_match("/\\bMAXSIZE\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], multiplicate($matches[1]), $myLine)); } } else { if (preg_match("/\\bMINSIZE\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], multiplicate($matches[1]), $myLine)); } } else { if (preg_match("/\\bMAXWIDTH\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], multiplicate($matches[1]), $myLine)); } } else { if (preg_match("/\\bMINWIDTH\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], multiplicate($matches[1]), $myLine)); } } else { if (preg_match("/\\bWIDTH\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { //fputs($myNewContent, "# ". $myLine); if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], multiplicate($matches[1]), $myLine)); } } else { if (preg_match("/\\bSYMBOLSCALEDENOM\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { //fputs($myNewContent, "# ". $myLine); if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], division($matches[1]), $myLine)); } } else { if (preg_match("/\\bMINSCALEDENOM\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { //fputs($myNewContent, "# ". $myLine); if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], division($matches[1]), $myLine)); } } else { if (preg_match("/\\bLABELMAXSCALEDENOM\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { //fputs($myNewContent, "# ". $myLine); if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], division($matches[1]), $myLine)); } } else { if (preg_match("/\\bLABELMINSCALEDENOM\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { //fputs($myNewContent, "# ". $myLine); if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], division($matches[1]), $myLine)); } } else { if (preg_match("/\\bMAXSCALEDENOM\\s*(\\d+.?\\d*)\\s*/i", $myLine, $matches)) { //fputs($myNewContent, "# ". $myLine); if (count($matches) <= 2) { fputs($myNewContent, str_replace($matches[1], division($matches[1]), $myLine)); } } else { if (preg_match("/\\bSYMBOLSET\\s*(.*)/i", $myLine, $matches)) { //noch nicht fertig $arraySymbolFiles[$countSymbolsFiles] = str_replace("\"", "", $matches[1]); $countSymbolsFiles++; fputs($myNewContent, $myLine); } else { fputs($myNewContent, $myLine); } } } } } } } } } } } } } } fclose($myContent); fclose($myNewContent); }
function mathOperation($arg1, $arg2, $operation) { switch ($operation) { case "sum": return "Результат сложения: " . sum($arg1, $arg2); break; case "multiplication": return "Результат умножения: " . multiple($arg1, $arg2); break; case "division": return "Результат деления: " . division($arg1, $arg2); break; case "subtraction": return "Результат вычитания: " . subtraction($arg1, $arg2); break; } }
$valor2 = $_POST["txtValor2"]; //$operacion = $_POST["txtOperacion"]; // para form.php $operacion = $_POST["rdbOperacion"]; // para form_radio.php switch ($operacion) { case 'suma': $resultado = suma($valor1, $valor2); break; case 'resta': $resultado = resta($valor1, $valor2); break; case 'multiplicacion': $resultado = multiplicacion($valor1, $valor2); break; case 'division': $resultado = division($valor1, $valor2); break; default: $resultado = suma($valor1, $valor2); break; } echo "El resultado de la operación " . $operacion . " es :" . $resultado; function suma($val1, $val2) { $resultado = $val1 + $val2; return $resultado; } function resta($val1, $val2) { $resultado = $val1 - $val2; return $resultado;