PHP code example of cs278 / serialization-helpers

1. Go to this page and download the library: Download cs278/serialization-helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cs278 / serialization-helpers example snippets




use Cs278\SerializationHelpers\isSerialized;

isSerialized('b:1');
// bool(false)

isSerialized('d:2.71828');
// bool(true)



use Cs278\SerializationHelpers\unserialize;
use Cs278\SerializationHelpers\Exception\SyntaxError;

try {
    return unserialize('s:"foobar";');
} catch (SyntaxError $e) {
    $logger->warning('Input, `{input}` was not valid serialized data', array(
        'input' => $e->getInput(),
    ));

    return null;
}