Le mardi 18 février 2020, 07:33:37 CET Paul M. Jones a écrit :
> ... the output would be "b\n". As you say, setContent() replaces whatever content is already in the ServerResponse. While the comparison for a single echo is accurate, the comparison for multiple echoes would be:
> $content = "a\n";
> $content .= "b\n";
> Does that help to clarify?
Yes, but to me that means we also need an addContent method.
Otherwise people will have to carry a global $content along side $response, or use setContent(getContent().$additionalContent).
FusionDirectory - https://www.fusiondirectory.org
February 18, 2020 14:email@example.com ("Paul M. Jones")
> On Feb 18, 2020, at 08:10, CÃ´me Chilliet firstname.lastname@example.org> wrote:
> to me that means we also need an addContent method.
I can see why we'd think that; it's symmetrical, if nothing else.
Even so, none of the researched implementations have a method like that. As far as I can recall, they call have setContent() and getContent() equivalents, but no addContent() equivalent. They all work much like you point out here ...
> Otherwise people will have to carry a global $content along side $response, or use setContent(getContent().$additionalContent).
.... although usually it's not a global $content. Instead, the $content is built up from a template or other subsystem of some sort, and then assigned to the response when complete. For example:
$content = $template->render();
So, I am reluctant to add something that no other implementations, across many years and many authors, have actually found a need for.
Any further thoughts on this?
Paul M. Jones
Modernizing Legacy Applications in PHP
Solving the N+1 Problem in PHP