fork(1) download
  1. <?php
  2.  
  3. class Point {
  4. var $x, $y;
  5.  
  6. function __construct($x, $y) {
  7. $this->x = $x;
  8. $this->y = $y;
  9. }
  10.  
  11. function distance($p) {
  12. return sqrt(($this->x - $p->x) * ($this->x - $p->x) + ($this->y - $p->y) * ($this->y - $p->y));
  13. }
  14. }
  15.  
  16. $a = new Point(3, 2);
  17. $b = new Point(5, 7);
  18.  
  19. print $a->distance($b);
  20.  
  21. ?>
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
5.38516480713