On Sat, 2009-05-09 at 18:35 +0200, Cesco wrote:
> 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
Presumably you're doing this on the shell (versus in a web page). You
need to send the newline ("\n") character since most terminals buffer
the output until a newline character is encountered. If htis is a
webpage you are in for even more trouble since browser often won't
output anything until they receive at least X bytes (where X depends on
the browser).
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php