4

I am trying to find the correct (or best) content type to pass to header() when outputting serialized PHP data. The best I could find when searching was a proposal for application/vnd.php.serialized and another person asking the same question without a definitive answer. I was considering using just text/plain and moving on. The data being serialized is an associative array, 1-3 levels nested. Values are always string/int/bool, in order of occurrence.

For reasoned I'd rather not get into, my application is using PHP4. Otherwise I would be using JSON and be on my way.

Edit: My question is not about how to work with JSON in PHP.
For those interested: I am handling JSON encode/decode using the 'Services_JSON' PEAR package , however I've noticed performance issues which PHP serialized resolves.

  • I don't think there is a definitive answer. As long as `text/plain` works for you then keep using it. – Technoh Apr 22 '16 at 16:38
  • 1
    Possible duplicate of [php4 with json data](http://stackoverflow.com/questions/3481927/php4-with-json-data) – splash58 Apr 22 '16 at 16:57
  • @Technoh - I'm inclined to agree and it is - wanted to see what other SO folks thought. – prefectionist Apr 22 '16 at 17:25
  • Thats a good question, I am looking for an answer to this since a very long time. To know what file-extension fits best is interresting too – Radon8472 Oct 25 '20 at 09:22

1 Answers1

0

I did not find a real official answer, but the best matching answer I can find is:

application/php-serialized

or better

application/php-serialized; charset=UTF-8
Radon8472
  • 4,285
  • 1
  • 33
  • 41