Check to see if a string is serialized?

前端 未结 11 1676
情歌与酒
情歌与酒 2020-11-29 17:16

What\'s the best way to determine whether or not a string is the result of the serialize() function?

https://www.php.net/manual/en/function.serialize

11条回答
  •  误落风尘
    2020-11-29 18:06

    /**
     * some people will look down on this little puppy
     */
    function isSerialized($s){
    if(
        stristr($s, '{' ) != false &&
        stristr($s, '}' ) != false &&
        stristr($s, ';' ) != false &&
        stristr($s, ':' ) != false
        ){
        return true;
    }else{
        return false;
    }
    
    }
    

提交回复
热议问题