PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/php4/shadow/runme.php4

#
PHP | 68 lines | 41 code | 15 blank | 12 comment | 0 complexity | 42cbfdd41bf6031a19c4c9cb2aeed1f7 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <?php
  2. # This file illustrates the low-level C++ interface
  3. # created by SWIG. In this case, all of our C++ classes
  4. # get converted into function calls.
  5. include("example.php");
  6. # ----- Object creation -----
  7. print "Creating some objects:\n";
  8. $c = CircleFactory(10);
  9. print " Created circle $c with area ". $c->area() ."\n";
  10. $s = new Square(10);
  11. print " Created square $s\n";
  12. # ----- Access a static member -----
  13. print "\nA total of " . Shape::nshapes() . " shapes were created\n";
  14. # ----- Member data access -----
  15. # Set the location of the object.
  16. # Note: methods in the base class Shape are used since
  17. # x and y are defined there.
  18. $c->x = 20;
  19. $c->y = 30;
  20. $s->x = -10;
  21. $s->y = 5;
  22. print "\nHere is their current position:\n";
  23. print " Circle = (" . $c->x . "," . $c->y . ")\n";
  24. print " Square = (" . $s->x . "," . $s->y . ")\n";
  25. # ----- Call some methods -----
  26. print "\nHere are some properties of the shapes:\n";
  27. foreach (array($c,$s) as $o) {
  28. print " ".get_class($o)." $o\n";
  29. print " x = " . $o->x . "\n";
  30. print " y = " . $o->y . "\n";
  31. print " area = " . $o->area() . "\n";
  32. print " perimeter = " . $o->perimeter() . "\n";
  33. }
  34. # Need to unset($o) or else we hang on to a reference to the Square object.
  35. unset($o);
  36. # ----- Delete everything -----
  37. print "\nGuess I'll clean up now\n";
  38. # Note: this invokes the virtual destructor
  39. unset($c);
  40. $s = 42;
  41. print Shape::nshapes() . " shapes remain\n";
  42. print "Manually setting nshapes\n";
  43. Shape::nshapes(42);
  44. print Shape::get_nshapes() ." == 42\n";
  45. print "Goodbye\n";
  46. ?>