1--TEST-- 2ZE2 Constructor precedence 3--FILE-- 4<?php 5class Base_php4 { 6 function Base_php4() { 7 var_dump('Base constructor'); 8 } 9} 10 11class Child_php4 extends Base_php4 { 12 function Child_php4() { 13 var_dump('Child constructor'); 14 parent::Base_php4(); 15 } 16} 17 18class Base_php5 { 19 function __construct() { 20 var_dump('Base constructor'); 21 } 22 } 23 24class Child_php5 extends Base_php5 { 25 function __construct() { 26 var_dump('Child constructor'); 27 parent::__construct(); 28 } 29 } 30 31class Child_mx1 extends Base_php4 { 32 function __construct() { 33 var_dump('Child constructor'); 34 parent::Base_php4(); 35 } 36} 37 38class Child_mx2 extends Base_php5 { 39 function Child_mx2() { 40 var_dump('Child constructor'); 41 parent::__construct(); 42 } 43} 44 45echo "### PHP 4 style\n"; 46$c4= new Child_php4(); 47 48echo "### PHP 5 style\n"; 49$c5= new Child_php5(); 50 51echo "### Mixed style 1\n"; 52$cm= new Child_mx1(); 53 54echo "### Mixed style 2\n"; 55$cm= new Child_mx2(); 56?> 57--EXPECTF-- 58Deprecated: 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 59 60Deprecated: 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 61 62Deprecated: 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 63### PHP 4 style 64string(17) "Child constructor" 65string(16) "Base constructor" 66### PHP 5 style 67string(17) "Child constructor" 68string(16) "Base constructor" 69### Mixed style 1 70string(17) "Child constructor" 71string(16) "Base constructor" 72### Mixed style 2 73string(17) "Child constructor" 74string(16) "Base constructor" 75