Something I don't understand about PHP classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:


<?php

    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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux