{"id":94,"date":"2012-11-14T19:51:52","date_gmt":"2012-11-14T11:51:52","guid":{"rendered":"http:\/\/www.yeetrack.com\/post\/2012-11-14\/php%25E5%25AF%25B9%25E8%25B1%25A1%25E4%25B8%25B2%25E8%25A1%258C%25E5%258C%2596"},"modified":"2013-04-20T17:27:20","modified_gmt":"2013-04-20T09:27:20","slug":"php%e5%af%b9%e8%b1%a1%e4%b8%b2%e8%a1%8c%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=94","title":{"rendered":"php\u5bf9\u8c61\u4e32\u884c\u5316"},"content":{"rendered":"<p>php\u5bf9\u8c61\u5b58\u5728\u4e8e\u8ba1\u7b97\u673a\u5185\u5b58\u4e2d\uff0c\u5982\u679c\u60f3\u5c06\u5bf9\u8c61\u4fdd\u5b58\u4e0b\u6765\uff0c\u5c31\u9700\u8981\u628a\u5bf9\u8c61\u4e32\u884c\u5316\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4e32\u884c\u5316\u5c31\u662f\u628a\u6574\u4e2a\u5bf9\u8c61\u8f6c\u5316\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u4f7f\u7528\u51fd\u6570serialize()\u3002\u5bf9\u8c61\u4e32\u884c\u5316\u7ecf\u5e38\u7528\u5728<\/p>\n<ul class=\"edui-filter-disc\">\n<li>\n<p>\u5bf9\u8c61\u9700\u8981\u5728\u7f51\u7edc\u4e2d\u4f20\u8f93<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u8c61\u9700\u8981\u6c38\u4e45\u4fdd\u5b58\uff0c\u4e32\u884c\u5316\u540e\u5199\u5165\u6587\u4ef6\u6216\u8005\u6570\u636e\u5e93\u3002<\/p>\n<\/li>\n<\/ul>\n<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e32\u884c\u5316\u7684\u9006\u8fc7\u7a0b\u662f\u53cd\u4e32\u884c\u5316\uff0c\u5c31\u662f\u628a\u5bf9\u8c61\u4e32\u884c\u5316\u8f6c\u5316\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u518d\u8f6c\u5316\u4e3a\u5bf9\u8c61\uff0c\u4f7f\u7528\u51fd\u6570unserialize()\u3002<\/p>\n<pre config=\"brush:php;toolbar:false;\">&lt;?php \n    \/**\n     * \u58f0\u660e\u4e00\u4e2aPerson\u7c7b\uff0c\u7528\u6765\u6f14\u793a\u5bf9\u8c61\u4e32\u884c\u5316\n     * @author  youthflies\n     *\/\n    class Person\n    {\n        private $name;\n        private $age;\n        private $email;\n             \n        \/\/\u58f0\u660e\u6784\u9020\u51fd\u6570\n        function __construct($name=&quot;Tom&quot;, $age=1, $email=&quot;helloworld@123.com&quot;)\n        {\n            $this-&gt;name = $name;\n            $this-&gt;age = $age;\n            $this-&gt;email = $email;\n        }\n             \n        public function printInfo()\n        {\n            echo &quot;&lt;br\/&gt;&quot; . $this-&gt;name . &quot;  &quot; . $this-&gt;age . &quot;  &quot; . $this-&gt;email . &quot;&lt;br \/&gt;&quot;;\n        }\n    }\n         \n    $person1 = new Person(&quot;yeetrack&quot;, 12, &quot;yeetrack@123.com&quot;);\n         \n    $person1_string = serialize($person1);\n    \/\/\u5c06\u4e32\u884c\u5316\u540e\u7684\u5b57\u7b26\u4e32\u6253\u5370\u51fa\u6765\n    echo $person1_string;\n    \/\/\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\n    file_put_contents(&quot;Person.txt&quot;, $person1_string);\n    \/\/\u5728\u5c06\u4e32\u884c\u5316\u4ea7\u751f\u7684\u5b57\u7b26\u4e32\u53cd\u4e32\u884c\u5316\n    $string = file_get_contents(&quot;Person.txt&quot;);\n    $persion2 = unserialize($string);\n    $persion2-&gt;printInfo();\n?&gt;<\/pre>\n<p>\u8fd0\u884c\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/m1.img.libdd.com\/farm5\/2012\/1114\/19\/0594230D9DAFBCA0F1DC25BFB933903D91A9F6E522BCA_500_28.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>php\u5bf9\u8c61\u5b58\u5728\u4e8e\u8ba1\u7b97\u673a\u5185\u5b58\u4e2d\uff0c\u5982\u679c\u60f3\u5c06\u5bf9\u8c61\u4fdd\u5b58\u4e0b\u6765\uff0c\u5c31\u9700\u8981\u628a\u5bf9\u8c61\u4e32\u884c\u5316\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[33],"tags":[24,7],"class_list":["post-94","post","type-post","status-publish","format-standard","hentry","category-coding","tag-php","tag-7"],"views":2538,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94"}],"version-history":[{"count":2,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":404,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions\/404"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}