当前位置: 首页>>代码示例>>PHP>>正文


PHP Calculator::sum方法代码示例

本文整理汇总了PHP中Calculator::sum方法的典型用法代码示例。如果您正苦于以下问题:PHP Calculator::sum方法的具体用法?PHP Calculator::sum怎么用?PHP Calculator::sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Calculator的用法示例。


在下文中一共展示了Calculator::sum方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testThatSumWorks

 public function testThatSumWorks()
 {
     $calculator = new Calculator();
     $this->assertEquals(2, $calculator->sum(1, 1));
 }
开发者ID:richardtemme,项目名称:jenkins-test,代码行数:5,代码来源:CalculatorTest.php

示例2: testSum

 public function testSum()
 {
     $cal = new Calculator();
     $this->assertEquals(4, $cal->sum(2, 2));
 }
开发者ID:animkaTT,项目名称:test,代码行数:5,代码来源:CalculatorTest.php

示例3: Calculator

<?php

Logger::log('Start');
$param1 = (int) (isset($_POST['param1']) ? $_POST['param1'] : $_GET['param1']);
$param2 = (int) (isset($_POST['param2']) ? $_POST['param2'] : $_GET['param2']);
Logger::log('Got params: %s and %s', [$param1, $param2]);
$calculator = new Calculator();
$result = $calculator->sum($param1, $param2);
echo '<div><b>Program "Calculator"</b><br><br>' . $param1 . ' + ' . $param2 . ' = <b>' . $result . '</b></div>';
Logger::log('Finish');
开发者ID:vatulya,项目名称:tasks,代码行数:10,代码来源:calculator.php

示例4:

        margin: 0 auto;
    }
    .container{
        margin-top: 70px;
    }
    </style>
</head>
<body>
<div class="container max-960">
    <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12"></div>
        <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
            <div class="panel panel-default">
                <div class="panel-body">
                <div class="panel-heading"><h3>Calculation = <?php 
echo $cal->sum();
?>
</h3></div>
                    <form role="form">
                      <div class="form-group">
                        <label for="val1">Value 1</label>
                        <input type="number"  name="val1" class="form-control" placeholder=" Enter number">
                      </div>
                         <select class="form-control" name="operator">
                            <?php 
$cal->get_Operator();
?>
                        </select>
                      <div class="form-group">
                        <label for="val2">Value 2</label>
                        <input type="number"  name="val2" class="form-control" placeholder=" Enter number">
开发者ID:c0defl0w,项目名称:php-calculator,代码行数:31,代码来源:index.php

示例5: sum

<?php

class Calculator
{
    private $number;
    public function sum($number)
    {
        $this->number = $number;
        $odd = 0;
        $even = 0;
        for ($i = 0; $i <= $this->number; $i++) {
            if ($i % 2 == 1) {
                $odd = $odd + $i;
            } else {
                $even = $even + $i;
            }
        }
        echo "sum of odd number between 1 to " . $this->number . "is" . $odd . "<br />";
        echo "sum of even number between 1 to " . $this->number . "is " . $even;
    }
}
$calc = new Calculator();
$calc->sum(100);
开发者ID:nraxz,项目名称:mathfunction,代码行数:23,代码来源:calculator.php

示例6: __invoke

 public function __invoke()
 {
     $input = file_get_contents(__DIR__ . "/../../input/Day12/Puzzle1");
     $calculator = new Calculator();
     $this->write("Total: " . $calculator->sum($input));
 }
开发者ID:garethellis36,项目名称:advent-of-code-2015,代码行数:6,代码来源:Puzzle1.php

示例7: Calculator

<?php

require_once 'lib/Calculator.php';
$calc = new Calculator();
echo $calc->sum(2, 2);
开发者ID:richardtemme,项目名称:jenkins-test,代码行数:5,代码来源:run.php


注:本文中的Calculator::sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。