inheritance_002.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --TEST--
  2. ZE2 Constructor precedence
  3. --SKIPIF--
  4. <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
  5. --FILE--
  6. <?php
  7. class Base_php4 {
  8. function Base_php4() {
  9. var_dump('Base constructor');
  10. }
  11. }
  12. class Child_php4 extends Base_php4 {
  13. function Child_php4() {
  14. var_dump('Child constructor');
  15. parent::Base_php4();
  16. }
  17. }
  18. class Base_php5 {
  19. function __construct() {
  20. var_dump('Base constructor');
  21. }
  22. }
  23. class Child_php5 extends Base_php5 {
  24. function __construct() {
  25. var_dump('Child constructor');
  26. parent::__construct();
  27. }
  28. }
  29. class Child_mx1 extends Base_php4 {
  30. function __construct() {
  31. var_dump('Child constructor');
  32. parent::Base_php4();
  33. }
  34. }
  35. class Child_mx2 extends Base_php5 {
  36. function Child_mx2() {
  37. var_dump('Child constructor');
  38. parent::__construct();
  39. }
  40. }
  41. echo "### PHP 4 style\n";
  42. $c4= new Child_php4();
  43. echo "### PHP 5 style\n";
  44. $c5= new Child_php5();
  45. echo "### Mixed style 1\n";
  46. $cm= new Child_mx1();
  47. echo "### Mixed style 2\n";
  48. $cm= new Child_mx2();
  49. ?>
  50. --EXPECT--
  51. ### PHP 4 style
  52. string(17) "Child constructor"
  53. string(16) "Base constructor"
  54. ### PHP 5 style
  55. string(17) "Child constructor"
  56. string(16) "Base constructor"
  57. ### Mixed style 1
  58. string(17) "Child constructor"
  59. string(16) "Base constructor"
  60. ### Mixed style 2
  61. string(17) "Child constructor"
  62. string(16) "Base constructor"