Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Oct 23 Previous

The first shall be the last

Consider the following program:


class A {
        const A = X::X;

class X {
        const X = 3;

echo A::A;


What will it display in your browser window?

A: 3
B: X
C: Notice: Use of undefined constant X - assumed 'X' in ... on line 4
D: A parse error


There is nothing wrong with this script. What you see here is a compile time depenency and the order in which the classes were defined doesn't matter: it will be resolved by PHP. Acutally you can cut line 11 and paste it on line 2 and it will work the same. So answer A is correct.