Howdy all, haven't posted in ages but good to see the list going strong.

I'd like a little background on something we've long accepted: why
does the serialization format need double quotes around a string, even
though the byte length is explicit?

Example:

  s:5:"hello";

All else being equal I would think we could have just

  s:5:hello;

and skip forward 5 bytes. Instead we need to be aware of the leading
and trailing " in our state machine but I'm not sure what the
advantage is.

Was this just to make strings look more 'stringy', even though the
format isn't meant to be human-readable?

I read (the archive of) Kris's blog post:

  
https://web.archive.org/web/20170813190508/http://blog.koehntopp.info/index.php/2407-php-understanding-unserialize/

but that didn't shed any light. Zigzagging through the source wasn't
getting me there as fast as someone who was there from the beginning.

The reason for my question is I'm writing a blog post about a SaaS app
that (don't gasp/laugh) returns serialize() format from one of its
APIs. In discussing why the PHP format can make sense vs. JSON, I
wanted to point to the faster parsing you get with length-prefixed
strings. Then I started wondering about why we have both the length
prefix and the extra quotes.

Thanks,

Sandy

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to