{"id":662,"date":"2012-06-16T18:48:10","date_gmt":"2012-06-16T10:48:10","guid":{"rendered":"http:\/\/blog.my0513.com\/?p=662"},"modified":"2012-06-16T18:54:40","modified_gmt":"2012-06-16T10:54:40","slug":"%e9%b8%a1%e7%94%9f%e8%9b%8b%ef%bc%8c%e8%9b%8b%e7%94%9f%e9%b8%a1%e3%80%82","status":"publish","type":"post","link":"https:\/\/blog.my0513.com\/?p=662","title":{"rendered":"\u9e21\u751f\u86cb\uff0c\u86cb\u751f\u9e21\u3002"},"content":{"rendered":"<p>\u89e3\u51b3PHP5.x\u751f\u6210Session\u7684\u95ee\u9898\uff0c\u7ea0\u7f20\u6570\u65e5\u3002<\/p>\n<blockquote><p><strong>Warning\u00a0<\/strong><\/p>\n<p>As of PHP 5.0.5 the\u00a0<em><code>write<\/code><\/em>\u00a0and\u00a0<em><code>close<\/code><\/em>\u00a0handlers are called after object destruction and therefore cannot use objects or throw exceptions. Exceptions are not able to be caught since will not be caught nor will any exception trace be displayed and the execution will just cease unexpectedly. The object destructors can however use sessions.<\/p>\n<p>It is possible to call\u00a0<a href=\"http:\/\/docs.php.net\/manual\/zh\/function.session-write-close.php\">session_write_close()<\/a>\u00a0from the destructor to solve this chicken and egg problem but the most reliable way is to register the shutdown function as described above.<\/p><\/blockquote>\n<p>\u76f8\u5173\u53c2\u8003URL\uff1a<a href=\"http:\/\/docs.php.net\/manual\/zh\/function.session-set-save-handler.php\">1<\/a>\u3001<a href=\"http:\/\/docs.php.net\/manual\/zh\/function.register-shutdown-function.php\">2<\/a>\u3001<a href=\"http:\/\/docs.php.net\/manual\/zh\/function.session-write-close.php\">3<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u51b3PHP5.x\u751f\u6210Session\u7684\u95ee\u9898\uff0c\u7ea0\u7f20\u6570\u65e5\u3002 Warning\u00a0 As of PHP 5.0.5 the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,1,32],"tags":[76,75,77,5,30],"class_list":["post-662","post","type-post","status-publish","format-standard","hentry","category-7","category-1","category-32","tag-chicken","tag-egg","tag-php-code","tag-5","tag-30"],"_links":{"self":[{"href":"https:\/\/blog.my0513.com\/index.php?rest_route=\/wp\/v2\/posts\/662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.my0513.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.my0513.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.my0513.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.my0513.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=662"}],"version-history":[{"count":2,"href":"https:\/\/blog.my0513.com\/index.php?rest_route=\/wp\/v2\/posts\/662\/revisions"}],"predecessor-version":[{"id":664,"href":"https:\/\/blog.my0513.com\/index.php?rest_route=\/wp\/v2\/posts\/662\/revisions\/664"}],"wp:attachment":[{"href":"https:\/\/blog.my0513.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.my0513.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.my0513.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}