Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

   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;