# redefined constructor: old and new syntax

- Thread: https://externals.io/message/8571
- Original archive: https://news-web.php.net/php.internals/8571
- Started by Lorenzo Alberton on 2004-03-18T00:28:00+00:00
- Messages: 2
- 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

---

## #8571 — Lorenzo Alberton — 2004-03-18T00:28:00+00:00

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

Why has this one been committed?

http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?login=2&r1=1.551&r2=1.552
&ty=h


It prevents constructors being redefined.
That is fine, *except* for the following case:

class MyClass
{
    function MyClass() {
        //constructor for php4,
        //SHOULD be ignored by php5
    }

    function __construct() {
        //constructor for php5,
        //ignored by php4
    }
}

i.e. it doesn't allow a class to work on both php4 and php5.
Or am I missing something obvious?

Best regards,
Lorenzo

---

## #8573 — Andi Gutmans — 2004-03-18T07:10:42+00:00

URL: https://externals.io/message/8571#8573 · In reply to: #8571

Well it doesn't really make sense to redefine a constructor. We added it on 
purpose. Do you want me to change it to E_STRICT?

At 01:28 AM 3/18/2004 +0100, Lorenzo Alberton wrote:
>Why has this one been committed?
>
>http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?login=2&r1=1.551&r2=1.552
>&ty=h
>
>
>It prevents constructors being redefined.
>That is fine, *except* for the following case:
>
>class MyClass
>{
>     function MyClass() {
>         //constructor for php4,
>         //SHOULD be ignored by php5
>     }
>
>     function __construct() {
>         //constructor for php5,
>         //ignored by php4
>     }
>}
>
>i.e. it doesn't allow a class to work on both php4 and php5.
>Or am I missing something obvious?
>
>Best regards,
>Lorenzo
