# php 5 bug?

- Thread: https://externals.io/message/7277
- Original archive: https://news-web.php.net/php.internals/7277
- Started by Nuno Lopes on 2004-01-22T16:05:20+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

---

## #7277 — Nuno Lopes — 2004-01-22T16:05:20+00:00

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

Hello,

I don't know if this is a bug or a feature, but... The code below works with
PHP 4, but gives an error in PHP 5.

Nuno


--------------------------------
<?php
$test = new test();
$test->func();

class test
{
    function func() {
        echo 'test';
    }
}
?>
-------------------
PHP 4:
test
-------------------
PHP 5:
Fatal error: Class 'test' not found in C:\...\bug.php on line 2

---

## #7278 — Christian Schneider — 2004-01-22T17:11:26+00:00

URL: https://externals.io/message/7277#7278 · In reply to: #7277

Nuno Lopes wrote:
> I don't know if this is a bug or a feature, but... The code below works with
> PHP 4, but gives an error in PHP 5.

Classes have to be defined before they are used in PHP5.

- Chris
