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


PHP multiply函数代码示例

本文整理汇总了PHP中multiply函数的典型用法代码示例。如果您正苦于以下问题:PHP multiply函数的具体用法?PHP multiply怎么用?PHP multiply使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: add

<?php

function add($a, $b)
{
    return $a + $b;
}
function subtract($a, $b)
{
    return $a - $b;
}
function multiply($a, $b)
{
    return $a * $b;
    // Add code here
}
function divide($a, $b)
{
    return $a / $b;
}
// Add code to test your functions here
echo add(4, 5);
echo subtract(18, 9);
echo multiply(3, 3);
echo divide(18, 3);
开发者ID:pswantner,项目名称:Codeup-Web-Excercises,代码行数:24,代码来源:arithmetic.php

示例2: multiply

function multiply($x, $y)
{
    if ($y == 1) {
        return $x;
    }
    return $x + multiply($x, $y - 1);
}
开发者ID:Just-Man,项目名称:PHP,代码行数:7,代码来源:Func_PowerPlus.php

示例3: multiply

function multiply($n, $m)
{
    if ($m == 1) {
        return $n;
    }
    return $n + multiply($n, $m - 1);
}
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:7,代码来源:power_with_addition.php

示例4: promptDivide

function promptDivide()
{
    $a = prompt("Enter a number (a) that you'd like to divide:");
    $b = prompt("Enter a number (b) that you'd like to divide by:");
    $c = prompt("Enter a number (c) that you'd like to multiply by:");
    return Attempt::call('divide', array($a, $b))->map(function ($elem) use($c) {
        return multiply($elem, $c);
    });
}
开发者ID:glensc,项目名称:php-try,代码行数:9,代码来源:user-input.php

示例5: mathOperation

function mathOperation($arg1, $arg2, $operation)
{
    switch ($operation) {
        case 'add':
            echo adding($arg1, $arg2);
            break;
        case 'substract':
            echo substracting($arg1, $arg2);
            break;
        case 'multiply':
            echo multiply($arg1, $arg2);
            break;
        case 'divide':
            echo divide($arg1, $arg2);
            break;
        default:
            echo "Вы не корректно определили параметры!";
            break;
    }
}
开发者ID:GonikDaniel,项目名称:php_study_project,代码行数:20,代码来源:item4.php

示例6: multiply

<?php

/*this is an example on global variable*/
$x = 5;
$y = 10;
function multiply($x, $y)
{
    echo $GLOBALS['x'] * $y;
}
multiply(3, 3);
//Output: 15
开发者ID:varunkumar82786,项目名称:Student002-php-exercises,代码行数:11,代码来源:96_global_variable.php

示例7: multiply

<?php

// multiplicar un valor por diez y retornarlo al invocador
function multiply($value)
{
    $value = $value * 10;
    return $value;
}
$retval = multiply(10);
print "Return value is {$retval}\n";
?>


开发者ID:leopachecoduran,项目名称:php-boilerplate,代码行数:11,代码来源:retornarvalor.php

示例8: multiply

<?php

function multiply($a, $b)
{
    $a * ($b = $c);
    return $c;
}
$newNumber = multiply(5, 6);
echo $newNumber;
echo "hello";
?>
<h1> Hello </h1>
开发者ID:sintija,项目名称:wordpress_backup,代码行数:12,代码来源:func.php

示例9: modulus

        } else {
            echo "ERROR: Cannot divide by 0\n";
        }
    }
}
function modulus($a, $b)
{
    $error = errorCheck($a, $b);
    if ($error) {
        if ($a != 0 && $b != 0) {
            return $a % $b;
        } else {
            echo "ERROR: Cannot divide by 0\n";
        }
    }
}
function errorCheck($a, $b)
{
    if (!is_numeric($a) || !is_numeric($b)) {
        echo "ERROR: Both arguments must be numbers\n";
        return false;
    } else {
        return true;
    }
}
// Add code to test your functions here
echo add(10, 2) . PHP_EOL;
echo subtract(10, 2) . PHP_EOL;
echo multiply(10, 2) . PHP_EOL;
echo divide(10, 2) . PHP_EOL;
echo modulus(10, 2) . PHP_EOL;
开发者ID:pascalallen,项目名称:Codeup_Exercises,代码行数:31,代码来源:arithmetic.php

示例10: multiply

<?php

$result = 0;
if (isset($_GET["multiply_numbers"])) {
    $result = multiply($_GET["var_one"], $_GET["var_two"]);
}
function multiply($x, $y)
{
    $answer = $x * $y;
    return $answer;
}
?>
<form method="get" >

	<input name="var_one"> * <input name="var_two">
	<input name="multiply_numbers" type="submit">
<form>

<p>Answer is <?php 
echo $result;
?>
 </p>
开发者ID:evilyeti89,项目名称:kordamine,代码行数:22,代码来源:calculator.php

示例11: array

<?php

$array = array(2, 4, 10, 16);
function multiply($array, $num)
{
    $result = array();
    foreach ($array as $key) {
        $product = $key * $num;
        array_push($result, $product);
    }
    var_dump($result);
}
multiply($array, 5);
开发者ID:kayeaborot,项目名称:Codes,代码行数:13,代码来源:intro8.php

示例12: multiply

<?php

echo '<h1>De uitkomst van de vermenigvuldiging:</h1>
		<h2>' . $valA . ' x ' . $valB . ' = ' . multiply($valA, $valB) . '</h2>';
开发者ID:siemdicou,项目名称:bewijzenmap,代码行数:4,代码来源:multiply.php

示例13: modulus

{
    if ($b == 0) {
        return 'ERROR: You are trying to destroy us all! ' . $a . ' ' . $b;
    }
    // $isValid = errorMessage($a, $b);
    if (validate($a, $b)) {
        return $a / $b;
    }
    // } else {
    // 	return $isValid;
    // }
}
function modulus($a, $b)
{
    if ($b == 0) {
        return 'ERROR: You are trying to destroy us all! ' . $a . ' ' . $b;
    }
    // $isValid = errorMessage($a, $b);
    if (validate($a, $b)) {
        return $a % $b;
    }
    // } else {
    // 	return $isValid;
    // }
}
echo add(9, "notNumeric") . PHP_EOL;
echo subtract(9, 3) . PHP_EOL;
echo multiply(9, 3) . PHP_EOL;
echo divide(9, 0) . PHP_EOL;
echo modulus(9, 3) . PHP_EOL;
// Add code to test your functions here
开发者ID:jewoodford,项目名称:php-exercises,代码行数:31,代码来源:arithmetic.php

示例14: operators

/*
 Using this regex we can split the string into an array based on the 4 math operators (+,-,/,*). 
 PREG_SPLIT_DELIM_CAPTURE returns the operators as part of the array.
*/
$stack = preg_split('/ *([+\\-\\/*]) */', $question, -1, PREG_SPLIT_DELIM_CAPTURE);
//The stack array must have a minimum of 3 elements to form a valid math operation: [A] [OPERATOR] [B]
while (sizeof($stack) >= 3) {
    switch ($stack[1]) {
        case "+":
            $answer = addition($stack[0], $stack[2]);
            break;
        case "-":
            $answer = subtract($stack[0], $stack[2]);
            break;
        case "*":
            $answer = multiply($stack[0], $stack[2]);
            break;
        case "/":
            $answer = divide($stack[0], $stack[2]);
            break;
    }
    //Remove the first 3 elements from the stack as they have been processed
    $stack = array_slice($stack, 3);
    //Add the current answer total to the beginning of the array for any further processes
    array_unshift($stack, $answer);
}
function addition($val1, $val2)
{
    return $val1 + $val2;
}
function subtract($val1, $val2)
开发者ID:TwirlWS,项目名称:commands,代码行数:31,代码来源:math.php

示例15: array

<?php

$A = array(2, 4, 10, 16);
//$n = 0;
function multiply($A, $n)
{
    $B = array();
    foreach ($A as $values) {
        $B[] = $values * $n;
    }
    var_dump($B);
}
multiply($A, 5);
开发者ID:jreyles,项目名称:lamp-stack,代码行数:13,代码来源:multiply5.php


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