inheritance_002.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. ZE2 Constructor precedence
  3. --FILE--
  4. <?php
  5. class Base_php4 {
  6. function Base_php4() {
  7. var_dump('Base constructor');
  8. }
  9. }
  10. class Child_php4 extends Base_php4 {
  11. function Child_php4() {
  12. var_dump('Child constructor');
  13. parent::Base_php4();
  14. }
  15. }
  16. class Base_php5 {
  17. function __construct() {
  18. var_dump('Base constructor');
  19. }
  20. }
  21. class Child_php5 extends Base_php5 {
  22. function __construct() {
  23. var_dump('Child constructor');
  24. parent::__construct();
  25. }
  26. }
  27. class Child_mx1 extends Base_php4 {
  28. function __construct() {
  29. var_dump('Child constructor');
  30. parent::Base_php4();
  31. }
  32. }
  33. class Child_mx2 extends Base_php5 {
  34. function Child_mx2() {
  35. var_dump('Child constructor');
  36. parent::__construct();
  37. }
  38. }
  39. echo "### PHP 4 style\n";
  40. $c4= new Child_php4();
  41. echo "### PHP 5 style\n";
  42. $c5= new Child_php5();
  43. echo "### Mixed style 1\n";
  44. $cm= new Child_mx1();
  45. echo "### Mixed style 2\n";
  46. $cm= new Child_mx2();
  47. ?>
  48. --EXPECTF--
  49. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Base_php4 has a deprecated constructor in %s on line %d
  50. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Child_php4 has a deprecated constructor in %s on line %d
  51. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Child_mx2 has a deprecated constructor in %s on line %d
  52. ### PHP 4 style
  53. string(17) "Child constructor"
  54. string(16) "Base constructor"
  55. ### PHP 5 style
  56. string(17) "Child constructor"
  57. string(16) "Base constructor"
  58. ### Mixed style 1
  59. string(17) "Child constructor"
  60. string(16) "Base constructor"
  61. ### Mixed style 2
  62. string(17) "Child constructor"
  63. string(16) "Base constructor"