Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122316 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14139 invoked from network); 6 Feb 2024 20:19:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Feb 2024 20:19:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707250831; bh=oZGCgIdlLqDmXh2lY8bv9vWZviXA1wb+WLmeF9485w4=; h=From:Date:Subject:To:From; b=ROzU1a46UdiJVSJPyBrxjOWA9ew0NQKd7NphuxVCrDnk4zTxw0SV9f8/OFafabTdW grHGQNI2R0rOVajKiOOBpdZV0QUAgMLYPvbi7api97M5i/rJmQEZsxtrqzg5Z+rE3r 9WaOZdBS/+/1I/eZ2cFQOaQKIRQ63uXKwkPhcQQfYslVoQFnKN5Gtf4bBGMckaeGB7 enMltVQMaUaNnu1Cf3W3t+YwGIQZpgCCuZ2K3qYJPbGBZZiV1Hh0caTLpq12gtUNf8 8mf6ObHu/Pgi5bslHZtMwBszZDCuOs6wTnIi4gaTAhFH6cj5UMDttrNymNFDYRWhYy u/1ndgYw+ewsw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0218E18005B for ; Tue, 6 Feb 2024 12:20:31 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, URIBL_SBL_A autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 6 Feb 2024 12:20:24 -0800 (PST) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-33b29b5ea96so616275f8f.0 for ; Tue, 06 Feb 2024 12:19:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707250771; x=1707855571; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=NZgqhHvIi0nD7pIhO1TUQ/srmTmB8zb0pq39Ton+d0Y=; b=PafI6tHZTKjF+h9P9sHyGyNBlJSxgT6YaWO6QQYumEOlVv0ZvOdn/cyHOHOeoFSbpR HammZcI/BTMa4GG8ROvwXAUx1QDvw+BpxxdK1+Or+CJC3TxSR5DYasC6mST6CaFIo5F3 c/29gT+OL9L2n+vLXVwk2+7g50nYnMFOHBoUUuZ0U5N03P2mMWLQpP9tiRpgIr7ONgfr 14LDj1G1QmjEpOXiIzd2ehoZ9KOoxe6X5wYgjh5hw7ZzR/fEIa5H2fWAGEKhucJhQAGR +AGn+SrEIGNAGZVV5ePuGnv2RnZbVZIdOlmkq2Suy5V7bmqRxrrwDdwpb7RBMP7TPan5 BjnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707250771; x=1707855571; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NZgqhHvIi0nD7pIhO1TUQ/srmTmB8zb0pq39Ton+d0Y=; b=K4B8xEOxIrEv1dDko7BLsfDSPjYosFp3M4URYuuF9IMCLRS49TLxWQR+Z8Bm8RZFW1 ipzUdhA4JXuAuw5ospVoPEbuVf+LdKJmh9FmkVr6GLhnodNsQkVGbqLmllWKDzEaIJ0U dHnvbv9hV8GsUwirr7sIkTVbqPDCytKcFpfZQ8+A1fK3oOotn6bnPMaeytoDQj3Sk//7 OS2Qjplj3ed6WnhzeziMeMw0d5O0Gx20a8M+zvNskSgpk//fGEu5Ts3cjNz2BIjYkhm7 4xSpBPiBLDoDhQ6SWR30io2E5zdA7tuytfRzot4PLQn1xj5uwHl66JIvPVQDbTGiZi8S CbjA== X-Gm-Message-State: AOJu0YzzU2v7gN8soG2NssXN3zamlDlHkDjTfbJxSLrQ6XLD21V+5Fz0 NtXadKIAarkpsXJhiJSB9g621rzF6noC7mp9bVAYdW8CzzEpJWOpSiVLb1rdk9VQuGEnKbkuZpV fO5dkFHxxOpApaf8Mc6ZGvGzMgty0JWFPNjI= X-Google-Smtp-Source: AGHT+IERtCCBnMXviZCb9xeaej1PAZVfgtC2IH54kBA26yZCK7njzjPbXJ9AcKAOBBA7gztnFNJyLd1M3W0RHstN150= X-Received: by 2002:a5d:4112:0:b0:33b:1a58:c70d with SMTP id l18-20020a5d4112000000b0033b1a58c70dmr1923937wrp.26.1707250770447; Tue, 06 Feb 2024 12:19:30 -0800 (PST) MIME-Version: 1.0 Date: Tue, 6 Feb 2024 15:19:19 -0500 Message-ID: To: PHP Internals Content-Type: text/plain; charset="UTF-8" Subject: Why are serialized strings wrapped in double quotes? (s::"") From: figureonecpr@gmail.com (Sanford Whiteman) 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