Re: Why does `setcookie` send header before throwing `Error` exception?

From: Date: Mon, 05 Apr 2021 00:17:15 +0000
Subject: Re: Why does `setcookie` send header before throwing `Error` exception?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-327539@lists.php.net to get a copy of this message
it looks like calling new foo() from within the class def would make it recursively trying to set the cookie. Actually, the class def begins in one line and ends in the next line (the line new Foo() is outside of the class def), did I misunderstand something?; it is similar to this:
class Foo {} which is small enough for illustrating what I think is a discrepancy between the two calls I mentioned in previous messages:
setcookie('name', 'value', 1, new Foo());
and
setcookie('name', 'value', array( 'expires' => 1, 'path' => new Foo() ));
The former does not send any header but the latter does.

« previous php.general (#327539) next »