improve headers_list() example#1007
Conversation
3da7c7a to
029df69
Compare
There was a problem hiding this comment.
These lines
doc-en/reference/network/functions/headers-list.xml
Lines 63 to 64 in 029df69
[0].
4f3fa6f to
862940b
Compare
There was a problem hiding this comment.
Thanks @hakre !
Added a few details that need to be fixed, as suggested changes.
Other things to consider changing, though not required:
- Change
&example.outputs;to&examples.outputs.similar;(i.e. to sayThe above examples will output something similar to:) since the output may vary by PHP version, configuration, SAPI (?), etc. These XML entities, and many others, can be found in thelanguage-snippets.entfile in the top-level directory of the repo. Update, or remove for simplicity, theEdit: it looks like you updated the version number while I was typing this. :)X-Powered-Byheader. PHP 5.1.3 is pretty ancient.
3395f29 to
ea085a3
Compare
|
There seems to be some non-signigifcant whitespace issue as well, I'll add it. |
|
I think I preferred your first version where you added |
Not sure I get what you mean. The header produced by PHP looks fine, doesn't it?: HTTP Header name fine, mime media type fine, charset attribute fine. not? @kamil-tekiela |
|
When you specify the charset explicitely then PHP will produce the header exactly as specified:
When you omit the charset, PHP will lowercase
The example given by MDN is
|
|
@kamil-tekiela: The whitespace is optional (OWS - optional white space) RFC 7231 Section 3.1.1.1 says:
and gives the following examples for media types in the Content-Type header:
The second and the last one come close to the one on MDN but actually the example on MDN is not in there.. I'd say it is another valid example. |
|
Thanks for pointing to the spec. I am aware the spaces are optional and the type, subtype and parameter are case-insensitive. I am not sure about the header name, but as I see user agents treat it in case insensitive way. My point is that when we document the output header, it would be safer to use the variant where PHP doesn't change the case or white space. What if we decide to change the |
Well it's docs and the example output is taken from the PHP version as in the X-Powered-By header. No decision for changes in src from my end, the examples should not imply anything regarding that from my perspective. Similar to the optional white space, case does not matter here (the header names are equivalent, similar to the token and quoted token in the media type). For the header names that is in the HTTP specs, MDN should have it as well as IETF. Therefore I don't see an issue with that. Also Additional ref regarding case-sensitivity: RFC 4790 9.2.1. ASCII Casemap Collation Description (non-locale-aware, Posix "C" locale like) But perhaps too technical for a docs discussion maybe @kamil-tekiela |
|
Sorry, maybe my language skills are at fault here. I am not questioning the RFC or why PHP outputs the header the way it does. All I am saying is that it's a little confusing for readers of the PHP manual to see that you are sending I am not sure how the discussion became technical; I did not mean to make it technical. All I said is that the example looked better when you had: The output will then be exactly what you provided to the |
|
Modified to |
kamil-tekiela
left a comment
There was a problem hiding this comment.
Thanks. Other than this one small change it looks good.
Two & 1/2 things with the PHP example code: 1. `X-` prefix header names June 2012 [1], [2]. 2. PHP prepends the `default_charset` [3] on any `text/*` media type in Content-Type header, unless the `charset` is with the `header()` call, like in the example. 3. PHP version 5.1.3 (May 2006) -> 8.0.11, the X-Powered-By header [4] removed (only distracting w/ the example). PHP version in use to generate the output: 8.0.11. [1]: https://datatracker.ietf.org/doc/html/rfc6648 [2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers [3]: https://www.php.net/manual/en/ini.core.php#ini.default-charset [4]: https://www.php.net/manual/en/ini.core.php#ini.expose-php Co-authored-by: Tiffany <tiffany.k.taylor@gmail.com>
Two & 1/2 things with the PHP example code: 1. `X-` prefix header names June 2012 [1], [2]. 2. PHP prepends the `default_charset` [3] on any `text/*` media type in Content-Type header, unless the `charset` is with the `header()` call, like in the example. 3. PHP version 5.1.3 (May 2006) -> 8.0.11, the X-Powered-By header [4] removed (only distracting w/ the example). PHP version in use to generate the output: 8.0.11. [1]: https://datatracker.ietf.org/doc/html/rfc6648 [2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers [3]: https://www.php.net/manual/en/ini.core.php#ini.default-charset [4]: https://www.php.net/manual/en/ini.core.php#ini.expose-php Co-authored-by: Tiffany <tiffany.k.taylor@gmail.com>
Two & 1/2 things with the PHP example code: 1. `X-` prefix header names June 2012 [1], [2]. 2. PHP prepends the `default_charset` [3] on any `text/*` media type in Content-Type header, unless the `charset` is with the `header()` call, like in the example. 3. PHP version 5.1.3 (May 2006) -> 8.0.11, the X-Powered-By header [4] removed (only distracting w/ the example). PHP version in use to generate the output: 8.0.11. [1]: https://datatracker.ietf.org/doc/html/rfc6648 [2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers [3]: https://www.php.net/manual/en/ini.core.php#ini.default-charset [4]: https://www.php.net/manual/en/ini.core.php#ini.expose-php Co-authored-by: Tiffany <tiffany.k.taylor@gmail.com>
|
Thank you. I merged it now. |
Two & 1/2 things with the PHP example code: 1. `X-` prefix header names June 2012 [1], [2]. 2. PHP prepends the `default_charset` [3] on any `text/*` media type in Content-Type header, unless the `charset` is with the `header()` call, like in the example. 3. PHP version 5.1.3 (May 2006) -> 8.0.11, the X-Powered-By header [4] removed (only distracting w/ the example). PHP version in use to generate the output: 8.0.11. [1]: https://datatracker.ietf.org/doc/html/rfc6648 [2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers [3]: https://www.php.net/manual/en/ini.core.php#ini.default-charset [4]: https://www.php.net/manual/en/ini.core.php#ini.expose-php Co-authored-by: Tiffany <tiffany.k.taylor@gmail.com>
Two things with the PHP example code:
X-prefix header names June 2012 1, 2.PHP prepends the
default_charset3 on anytext/*media type in Content-Type header (unless thecharsetis with theheader()call. The example code output now has it (with the UTF-8 default).