Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

   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;