VersionPress\Utils\StringUtils::isSerializedValue PHP 메소드

isSerializedValue() 공개 정적인 메소드

..).
public static isSerializedValue ( $value ) : boolean
$value
리턴 boolean
    public static function isSerializedValue($value)
    {
        /** @noinspection PhpUsageOfSilenceOperatorInspection */
        $test = @unserialize($value);
        // it throws an error and returns false if $value is not a serialized object
        return $test !== false || $value === 'b:0;';
    }

Usage Example

예제 #1
0
 private static function serializeData($data)
 {
     $output = [];
     foreach ($data as $key => $value) {
         if ($key == '') {
             continue;
         }
         if (is_array($value)) {
             foreach ($value as $arrayKey => $arrayValue) {
                 $output[] = self::serializeKeyValuePair($key . "[{$arrayKey}]", $arrayValue);
             }
         } elseif (StringUtils::isSerializedValue($value)) {
             $lines = SerializedDataToIniConverter::toIniLines($key, $value);
             $output = array_merge($output, $lines);
         } else {
             $output[] = self::serializeKeyValuePair($key, $value);
         }
     }
     return $output;
 }