PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Muhammad Umer Farooq   PHP Arithmetic Operations   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Arithmetic Operations
Perform calculations with values passed as strings
Author: By
Last change: Apply fixes from StyleCI
Date: 6 years ago
Size: 657 bytes
 

Contents

Class file image Download
<?php

require_once 'classes/Arithmetic.php';

$add = '10,20,-30,40,50,60';
$mul = '2,2,5,10';
$sub = '20,10';
$div = '1000,20,5,2';
$avg = '10,20,30,40,50,60';
$addition = Arithmetic::Calculate($add, 'addition');
$multiplication = Arithmetic::Calculate($mul, 'multiplication');
$substraction = Arithmetic::Calculate($sub, 'substraction');
$divisin = Arithmetic::Calculate($div, 'division');
$average = Arithmetic::Calculate($avg, 'average');

echo
'Addition: '.$addition;
echo
'<br>';
echo
'multiplication: '.$multiplication;
echo
'<br>';
echo
'Substraction: '.$substraction;
echo
'<br>';
echo
'divisin: '.$divisin;
echo
'<br>';
echo
'average: '.$average;