# Regression on constructor calls

- Thread: https://externals.io/message/40308
- Original archive: https://news-web.php.net/php.internals/40308
- Started by Remi Collet on 2008-09-07T07:34:33+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #40308 — Remi Collet — 2008-09-07T07:34:33+00:00

URL: https://externals.io/message/40308#40308

Calling a not defined constructor produce an error in PHP 5.3.0 alpha2
(200809070630 snapshot) when it work in php <= 5.2.6 calling the parent one.

Ok using constructor with class name is a compatibility behaviour and
using __construct don't have this issue. But this regression could
introduce breakage of old apps.

Regards
Remi



Simple test :
<?php
class newA {
	function __construct () {
		echo "from New A\n";
	}
}
class newB extends newA {
}
class newC extends newB {
	function __construct () {
		parent::__construct();
		echo "from New C\n";
	}
}
class oldA {
	function oldA () {
		echo "from Old A\n";
	}
}
class oldB extends oldA {
}
class oldC extends oldB {
	function oldC () {
		parent::oldB();
		echo "from Old C\n";
	}
}
echo "PHP Version : " . `phpversion()` . "\n";
$toto = new newC();
$toto = new oldC();
?>

PHP Version : 5.2.6
from New A
from New C
from Old A
from Old C

PHP Version : 5.3.0alpha3-dev
from New A
from New C
PHP Fatal error:  Call to undefined method oldB::oldB() in
/home/remif9/test/cons.php on line 24
