<?php
class A
{
function __construct( $dataA = false ) {
echo "constructor A enter data = $dataA \n " ;
$dataA .= "A" ;
echo "constructor A exit data = $dataA \n " ;
return $dataA ;
}
}
class B extends A
{
function __construct( $data = false ) {
echo "constructor B enter data = $data \n " ;
$dataB = parent:: __construct( $data ) ;
$dataB .= "B" ;
echo "constructor B exit data = $dataB \n " ;
return $dataB ;
}
}
class C extends B {
function __construct( $data = false ) {
echo "constructor C enter data = $data \n " ;
$dataC = parent:: __construct( $data ) ;
$dataC .= "C" ;
echo "constructor C exit data = $dataC \n " ;
$this -> temp = $dataC ;
}
}
$c = new C( "D" ) ;
PD9waHAKCmNsYXNzIEEgCnsKCWZ1bmN0aW9uIF9fY29uc3RydWN0KCRkYXRhQSA9IGZhbHNlKSB7CgkJZWNobyAiY29uc3RydWN0b3IgQSBlbnRlciBkYXRhID0gJGRhdGFBXG4iOwoJCSRkYXRhQSAuPSAiQSI7CgkJZWNobyAiY29uc3RydWN0b3IgQSBleGl0IGRhdGEgPSAkZGF0YUFcbiI7CgkKCQlyZXR1cm4gJGRhdGFBOwoJfQoJCQp9CgpjbGFzcyBCIGV4dGVuZHMgQSAKewoJZnVuY3Rpb24gX19jb25zdHJ1Y3QoJGRhdGEgPSBmYWxzZSkgewoJCWVjaG8gImNvbnN0cnVjdG9yIEIgZW50ZXIgZGF0YSA9ICRkYXRhXG4iOwoJCSRkYXRhQiA9IHBhcmVudDo6X19jb25zdHJ1Y3QoJGRhdGEpOwoJCSRkYXRhQiAuPSAiQiI7CgkJZWNobyAiY29uc3RydWN0b3IgQiBleGl0IGRhdGEgPSAkZGF0YUJcbiI7CgkJcmV0dXJuICRkYXRhQjsKCX0KCQp9CgpjbGFzcyBDIGV4dGVuZHMgQiB7CglmdW5jdGlvbiBfX2NvbnN0cnVjdCgkZGF0YSA9IGZhbHNlKXsKCWVjaG8gImNvbnN0cnVjdG9yIEMgZW50ZXIgZGF0YSA9ICRkYXRhXG4iOwoJJGRhdGFDID0gcGFyZW50OjpfX2NvbnN0cnVjdCgkZGF0YSk7CgkkZGF0YUMgLj0gIkMiOwoJZWNobyAiY29uc3RydWN0b3IgQyBleGl0IGRhdGEgPSAkZGF0YUNcbiI7CgkkdGhpcy0+dGVtcCA9ICRkYXRhQzsKCX0KfQoKJGMgPSBuZXcgQygiRCIpOwp2YXJfZHVtcCgkYyk7