Thank you for that answer. I think this is quite complicated for calling the header function one or multiple times. But appending multiple headers could´t be solved in another way, i think.
You can´t give multiple headers to the header() function at one, right?
And what is the best way to enhance the documentation? Simply a pull request to the getkirby.com repository?
I was looking an the core code and asked myself, why there is a check, if the string is callable. But if it´s not a string, but a function, this makes sense.
That the option is called headers was only a typo in the post. It´s fine in my code.
That’s true. Maybe the core should also support a string (like in your example) or an array for multiple headers.
I don’t think so.
Yep, exactly.
Actually it could be a string (name of the function to use) or an array (class or instance and method name). So is_callable() === true does not necessarily imply that is_string() === false. #phpIsBest
Yes I know. I researched a bit about the is_callable() function. But only giving a function name does not get me to the result I want to have - adding some response headers to my website. But thank you.
I will continue my work on a wildcard für the template given to the headers option tomorrow. And I will experiment a bit with making this option more intuitive (simply passing the headers to append instead of passing a whole function).
Yes, but for more complex operations it will be better to have the currently implemented version. It´s a little bit more to write, but I think, that the headers option is something quite special. Not everyone has to use it.
Adding a second version to define which headers should be send, would add complexity which is not necessary. What do you think? I will simply enhance the docs, so that everyone has an example how to do it.