PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/php/callback/runme.php

#
PHP | 47 lines | 25 code | 15 blank | 7 comment | 0 complexity | 3bb65d3070c9428657770f5c850fe2ec MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <?php
  2. # This file illustrates the cross language polymorphism using directors.
  3. require("example.php");
  4. # Class, which overwrites Callback::run().
  5. class PhpCallback extends Callback {
  6. function run() {
  7. print "PhpCallback.run()\n";
  8. }
  9. };
  10. # Create an Caller instance
  11. $caller = new Caller();
  12. # Add a simple C++ callback (caller owns the callback, so
  13. # we disown it first by clearing the .thisown flag).
  14. print "Adding and calling a normal C++ callback\n";
  15. print "----------------------------------------\n";
  16. $callback = new Callback();
  17. $callback->thisown = 0;
  18. $caller->setCallback($callback);
  19. $caller->call();
  20. $caller->delCallback();
  21. print "\n";
  22. print "Adding and calling a PHP callback\n";
  23. print "------------------------------------\n";
  24. # Add a PHP callback.
  25. $callback = new PhpCallback();
  26. $callback->thisown = 0;
  27. $caller->setCallback($callback);
  28. $caller->call();
  29. $caller->delCallback();
  30. # All done.
  31. print "php exit\n";
  32. ?>