本文整理汇总了PHP中multiply函数的典型用法代码示例。如果您正苦于以下问题:PHP multiply函数的具体用法?PHP multiply怎么用?PHP multiply使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了multiply函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: add
<?php
function add($a, $b)
{
return $a + $b;
}
function subtract($a, $b)
{
return $a - $b;
}
function multiply($a, $b)
{
$tot = 0;
for ($i = 0; $i < $a; $i++) {
$tot += $b;
}
return $tot;
}
function divide($a, $b)
{
return $a / $b;
}
echo "add: " . add(6, 4) . PHP_EOL;
echo "sub: " . subtract(12, 2) . PHP_EOL;
echo "mul: " . multiply(5, 2) . PHP_EOL;
echo "div: " . divide(20, 2) . PHP_EOL;
开发者ID:sprov03,项目名称:Codeup-Web-Exercises,代码行数:26,代码来源:arithmetic.php
示例17: highestMultiplePrimes
if ($primeCheck == 0) {
return FALSE;
}
}
return TRUE;
}
function highestMultiplePrimes($primes, $max)
{
foreach ($primes as $prime) {
$int = $prime;
while ($int + $prime <= $max) {
$int = $int + $prime;
}
$numbers[] = $int;
}
$numbers = array_unique($numbers);
return $numbers;
}
function multiply($numbers)
{
$result = 1;
foreach ($numbers as $number) {
$result = $result * $number;
}
return $result;
}
$max = 20;
$primes = getPrimes($max);
$numbers = highestMultiplePrimes($primes, $max);
$result = multiply($numbers);
print "{$result}";
开发者ID:TianliJin,项目名称:Zietlow-Collection,代码行数:31,代码来源:no5.php
示例18: multiply
require_once 'include/TinyAjax.php';
// Refactor and calculate everything here (AJAX-callback and POST)
function multiply($x, $y)
{
return $x * $y;
}
// Some default-values (but call multiply() to calculate default-result
$number1 = 2;
$number2 = 3;
$result = multiply($number1, $number2);
// If we have a post then get new numbers and calculate result
if (!empty($_POST['number1']) && !empty($_POST['number2'])) {
$number1 = $_POST['number1'];
$number2 = $_POST['number2'];
$result = multiply($number1, $number2);
}
// Ajax-code
$ajax = new TinyAjax();
$ajax->exportFunction("multiply", array("number1", "number2"), "#result");
$ajax->process();
?>
<html>
<head>
<title>TinyAjax-calculator</title>
<?php
$ajax->drawJavaScript(false, true);
?>
</head>
开发者ID:eznibe,项目名称:north-stock,代码行数:30,代码来源:ajax_test.php
示例19: multiply
<?php
function multiply($firstPicture, $twoPicture, $x, $y)
{
$img = new Imagick($firstPicture);
$img->thumbnailImage(140, 140);
$shadow = $img->clone();
$shadow->setImageBackgroundColor(new ImagickPixel('black'));
//color shadow
$shadow->shadowImage(80, 3, 5, 5);
//create shadow
$shadow->compositeImage($img, Imagick::COMPOSITE_OVER, 0, 0);
header("Content-Type: image/jpeg");
$img2 = new Imagick($twoPicture);
$img2->compositeImage($shadow, $shadow->getImageCompose(), $x, $y);
echo $img2;
}
multiply($firstPicture = 'source.png', $twoPicture = 'good.jpg', $x = 166, $y = 295);
开发者ID:Arxemond777,项目名称:Multiply,代码行数:18,代码来源:indexMultiply.php
示例20: subtract
}
function subtract($a, $b, $order = true)
{
return ($order ? $a - $b : $b - $a) . PHP_EOL;
}
function multiply($a, $b)
{
return $a * $b . PHP_EOL;
}
function divide($a, $b, $order = true)
{
return ($order ? $a / $b : $b / $a) . PHP_EOL;
}
echo subtract(10, 5, false);
echo add(10, 5);
echo multiply(10, 5);
echo divide(10, 5, false);
?>
</section>
<section id="exercise6">
<h3>Exercise 6</h3>
<p>Create a function which can accept any number of integer arguments and which returns their sum.</p>
<?php
function sum()
{
$sum = 0;
if (func_num_args() > 0) {
//check number of args supplied
foreach (func_get_args() as $arg) {
开发者ID:alexspit,项目名称:zendengineer,代码行数:31,代码来源:lesson2_homework.php
注:本文中的multiply函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论