Ok, I suppose that this should be a very simple problem and probably the answer is obvious, but I really can't understand how the classes and the rest of the stuff works in PHP...

Let's suppose that we have this piece of code:


    class Duck {
                function __construct() {
                        while(1==1) {
                                // This is an infinite loop
        echo "Hello world...";
        $DonaldDuck = new Duck();

I have put an infinite loop in the class constructor just to introduce a problem that will halt the execution of the PHP code.

Now, If I run this code I would expect that the PHP interpreter would print the "Hello world..." string, and then it should call the class constructor with the infinite loop inside of it.

But that doesn't happen.

Instead, the PHP interpreter enters IMMEDIATELY into an infinite loop, as if the variables were declared immediately and then the rest of the code is executed.

Is it right? Because I'm having really hard times in debugging a PHP class

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to