{"id":344,"date":"2013-12-27T15:22:33","date_gmt":"2013-12-27T07:22:33","guid":{"rendered":"http:\/\/www.zyuns.com\/?p=344"},"modified":"2015-02-15T20:46:33","modified_gmt":"2015-02-15T12:46:33","slug":"php-ri-chang-yan-zheng","status":"publish","type":"post","link":"https:\/\/www.siediyer.cn\/?p=344","title":{"rendered":"PHP\u65e5\u5e38\u9a8c\u8bc1"},"content":{"rendered":"<pre class=\"wrap:true lang:default decode:true \">&lt;?php\n\n\/*\n*    Author : lemonice\n*\n*    Email:chengciming@126.com\n*\n*    \u65f6\u95f4\uff1a2011-11\n*\n*    \u8bf4\u660e\uff1a\u9a8c\u8bc1\u65e5\u5e38\u683c\u5f0f\uff08Email\u7b49\uff09\n*\n*\/\n\n\/**\n * \u9a8c\u8bc1\u8f93\u5165\u7684\u90ae\u4ef6\u5730\u5740\u662f\u5426\u5408\u6cd5\n *\n * @access  public\n * @param   string      $user_email      \u9700\u8981\u9a8c\u8bc1\u7684\u90ae\u4ef6\u5730\u5740\n *\n * @return bool\n *\/\nfunction is_email($user_email)\n{\n    $chars = \"\/^([a-z0-9+_]|-|.)+@(([a-z0-9_]|-)+.)+[a-z]{2,6}$\/i\";\n    if (strpos($user_email, '@') !== false &amp;&amp; strpos($user_email, '.') !== false)\n    {\n        if (preg_match($chars, $user_email))\n        {\n            return true;\n        }\n        else\n        {\n            return false;\n        }\n    }\n    else\n    {\n        return false;\n    }\n}\n\n\/**\n * \u9a8c\u8bc1\u8f93\u5165\u7684\u624b\u673a\u53f7\u7801\n *\n * @access  public\n * @param   string      $user_mobile      \u9700\u8981\u9a8c\u8bc1\u7684\u624b\u673a\u53f7\u7801\n *\n * @return bool\n *\/\nfunction is_mobile($user_mobile)\n{\n    $chars = \"\/^(((d{2,3}))|(d{3}-))?1(3|5|8|9)d{9}$\/\";\n\n\tif (preg_match($chars, $user_mobile))\n\t{\n\t\treturn true;\n\t}else\n\t{\n\t\treturn false;\n\t}\n}\n\n\/**\n * \u9a8c\u8bc1\u8f93\u5165\u7684\u7535\u8bdd\u53f7\u7801\n *\n * @access  public\n * @param   string      $user_phone      \u9700\u8981\u9a8c\u8bc1\u7684\u7535\u8bdd\u53f7\u7801\n *\n * @return bool\n *\/\nfunction is_phone($user_phone)\n{\n    $chars = \"\/^(((d{2,3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,7}(-d{1,4})?$\/\";\n\n\tif (preg_match($chars, $user_phone))\n\t{\n\t\treturn true;\n\t}else\n\t{\n\t\treturn false;\n\t}\n}\n\n\/**\n * \u9a8c\u8bc1\u8f93\u5165\u7684\u7f51\u5740\n *\n * @access  public\n * @param   string      $user_url      \u9700\u8981\u9a8c\u8bc1\u7684\u7f51\u5740\n *\n * @return bool\n *\/\nfunction is_url($user_url)\n{\n    $chars = \"\/((^http)|(^https)|(^ftp)):\/\/(S)+.(w)+\/\";\n\n\tif (preg_match($chars, $user_url))\n\t{\n\t\treturn true;\n\t}else\n\t{\n\t\treturn false;\n\t}\n}\n\n\/**\n * \u9a8c\u8bc1\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u662f\u5426\u5e26\u6709\u7279\u6b8a\u7b26\u53f7\n *\n * @access  public\n * @param   string      $user_safe      \u9700\u8981\u9a8c\u8bc1\u7684\u5b57\u7b26\u4e32\n *\n * @return bool\n *\/\nfunction is_safe($user_safe)\n{\n    $chars = \"\/^(([A-Z]*|[a-z]*|d*|[-_~!@#$%^&amp;*.()[]{}&lt;&gt;?\/'\"]*)|.{0,5})$|s\/\";\n\n\tif (!preg_match($chars, $user_safe))\n\t{\n\t\treturn true;   \/\/\u627e\u4e0d\u5230\u7279\u6b8a\u5b57\u7b26\u5219\u8fd4\u56detrue\n\t}else\n\t{\n\t\treturn false;\n\t}\n}\n\n\/**\n * \u68c0\u67e5\u662f\u5426\u4e3a\u4e00\u4e2a\u5408\u6cd5\u7684\u65f6\u95f4\u683c\u5f0f\n *\n * @access  public\n * @param   string  $time   \u683c\u5f0f:2011-11-16 15:54:13\n * @return  void\n *\/\nfunction is_time($time)\n{\n    $pattern = '\/[d]{4}-[d]{1,2}-[d]{1,2}s[d]{1,2}:[d]{1,2}:[d]{1,2}\/';\n\n    return preg_match($pattern, $time);\n}\n\n?&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php \/* * Author : lemonice * * Email:chengciming@1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-344","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=344"}],"version-history":[{"count":1,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/344\/revisions"}],"predecessor-version":[{"id":421,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/344\/revisions\/421"}],"wp:attachment":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}