Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402]

   1  <?php
   2  
   3  use Complex\Complex as Complex;
   4  use Complex\Operations;
   5  
   6  include(__DIR__ . '/../vendor/autoload.php');
   7  
   8  $values = [
   9      new Complex(123),
  10      new Complex(456, 123),
  11      new Complex(0.0, 456),
  12  ];
  13  
  14  foreach ($values as $value) {
  15      echo $value, PHP_EOL;
  16  }
  17  
  18  echo 'Addition', PHP_EOL;
  19  
  20  $result = Operations::add(...$values);
  21  echo '=> ', $result, PHP_EOL;
  22  
  23  echo PHP_EOL;
  24  
  25  echo 'Subtraction', PHP_EOL;
  26  
  27  $result = Operations::subtract(...$values);
  28  echo '=> ', $result, PHP_EOL;
  29  
  30  echo PHP_EOL;
  31  
  32  echo 'Multiplication', PHP_EOL;
  33  
  34  $result = Operations::multiply(...$values);
  35  echo '=> ', $result, PHP_EOL;