note 127782 added to function.unserialize

From: Date: Thu, 20 Oct 2022 09:34:02 +0000
Subject: note 127782 added to function.unserialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-219732@lists.php.net to get a copy of this message
ERRATA CORRIGE: For those who are looking for an efficient solution for handling controversial "FALSE", they can use this function which in case of non-unserializable string, instead of a "FALSE", throws an Exception. Vice versa it returns the unserialized variable. <?php /** * @param string $serializedString * @param array $options * @return mixed * @throws Exception */ function UnSerialize(string $serializedString, array $options = []) { $_unserialized = @unserialize($serializedString, $options); if ($serializedString === serialize(false) || $_unserialized !== false){ return $_unserialized; } throw new Exception("Non-unserializable string"); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.161 (proxied: 151.19.23.136) ---- Manual Page -- https://php.net/manual/en/function.unserialize.php Edit -- https://main.php.net/note/edit/127782 Del: integrated -- https://main.php.net/note/delete/127782/integrated Del: useless -- https://main.php.net/note/delete/127782/useless Del: bad code -- https://main.php.net/note/delete/127782/bad+code Del: spam -- https://main.php.net/note/delete/127782/spam Del: non-english -- https://main.php.net/note/delete/127782/non-english Del: in docs -- https://main.php.net/note/delete/127782/in+docs Del: other reasons-- https://main.php.net/note/delete/127782 Reject -- https://main.php.net/note/reject/127782 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219732) next »