PHP code example of mugesh / calculator

1. Go to this page and download the library: Download mugesh/calculator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mugesh / calculator example snippets



Mugesh\Calculator\Calculator;

$calc = new Calculator();

// Basic operations
echo $calc->add(5, 3);        // 8
echo $calc->subtract(10, 4);  // 6
echo $calc->multiply(6, 7);   // 42
echo $calc->divide(15, 3);    // 5

// Advanced operations
echo $calc->percentage(200, 15);  // 30 (15% of 200)
echo $calc->power(2, 8);          // 256
echo $calc->sqrt(64);             // 8