fork download
  1. <?php
  2.  
  3. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
  4.  
  5. class O {
  6. private $X;
  7.  
  8. function __construct($x) {
  9. $this->X = $x;
  10. }
  11. function swap($otherO) {
  12. echo $this->X.' '.$otherO->X."\n";
  13.  
  14. $otherOX = $otherO->X;
  15. $otherO->X = $this->X;
  16. $this->X = $otherOX;
  17.  
  18. echo $this->X.' '.$otherO->X;
  19. }
  20. }
  21.  
  22.  
  23.  
  24. $L = new O(2);
  25. $R = new O(10);
  26.  
  27. $L->swap($R);
Success #stdin #stdout 0.02s 24344KB
stdin
Standard input is empty
stdout
2 10
10 2