/tags/rel-2.0.2/Examples/php/disown/runme.php

# · PHP · 49 lines · 20 code · 17 blank · 12 comment · 0 complexity · a7affe1a1e747a4c122961eb7cd8304e MD5 · raw file

  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. require("example.php");
  6. # ----- Object creation -----
  7. print "Creating some objects:\n";
  8. $c = new Circle(10);
  9. print " Created circle \$c\n";
  10. $s = new Square(10);
  11. print " Created square \$s\n";
  12. # ----- Create the ShapeContainer ----
  13. $container = new ShapeContainer();
  14. $container->addShape($c);
  15. $container->addShape($s);
  16. # ----- Access a static member -----
  17. print "\nA total of " . Shape::nshapes() . " shapes were created\n";
  18. # ----- Delete by the old references -----
  19. # This should not truely delete the shapes because they are now owned
  20. # by the ShapeContainer.
  21. print "Delete the old references.";
  22. # Note: this invokes the virtual destructor
  23. $c = NULL;
  24. $s = NULL;
  25. print "\nA total of " . Shape::nshapes() . " shapes remain\n";
  26. # ----- Delete by the container -----
  27. # This should truely delete the shapes
  28. print "Delete the container.";
  29. $container = NULL;
  30. print "\nA total of " . Shape::nshapes() . " shapes remain\n";
  31. print "Goodbye\n";
  32. ?>