{"id":462,"date":"2025-06-10T20:47:38","date_gmt":"2025-06-10T12:47:38","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/jcyy\/462.html"},"modified":"2025-06-10T20:47:38","modified_gmt":"2025-06-10T12:47:38","slug":"php%ef%bc%9a%e6%a3%80%e6%9f%a5%e4%b8%a4%e4%b8%aa%e6%97%a5%e6%9c%9f%e8%8c%83%e5%9b%b4%e6%98%af%e5%90%a6%e9%87%8d%e5%8f%a0","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/462.html","title":{"rendered":"PHP\uff1a\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u8303\u56f4\u662f\u5426\u91cd\u53e0"},"content":{"rendered":"<p><body><\/p>\n<h2>&#20171;&#32461;<\/h2>\n<p>&#22312;&#22788;&#29702;&#25490;&#26399;&#12289;&#39044;&#35746;&#25110;&#20854;&#20182;&#28041;&#21450;&#26102;&#38388;&#33539;&#22260;&#30340;&#31995;&#32479;&#26102;&#65292;&#30830;&#23450;&#20004;&#20010;&#26085;&#26399;&#33539;&#22260;&#26159;&#21542;&#37325;&#21472;&#26159;&#19968;&#39033;&#24120;&#35265;&#30340;&#25361;&#25112;&#12290;&#36825;&#20010;&#38382;&#39064;&#21487;&#20197;&#36890;&#36807;PHP&#39640;&#25928;&#22320;&#35299;&#20915;&#12290;<\/p>\n<h2>&#29702;&#35299;&#22522;&#30784;&#27010;&#24565;<\/h2>\n<p>&#22312;&#28145;&#20837;&#20195;&#30721;&#20043;&#21069;&#65292;&#29702;&#35299;&#37325;&#21472;&#26085;&#26399;&#33539;&#22260;&#33267;&#20851;&#37325;&#35201;&#12290;&#20004;&#20010;&#26085;&#26399;&#33539;&#22260;&#37325;&#21472;&#22914;&#26524;&#23427;&#20204;&#33267;&#23569;&#26377;&#19968;&#22825;&#20849;&#36890;&#12290;&#35299;&#20915;&#36825;&#20010;&#38382;&#39064;&#30340;&#26680;&#24515;&#24605;&#24819;&#22312;&#20110;&#27604;&#36739;&#27599;&#20010;&#33539;&#22260;&#30340;&#36215;&#22987;&#21644;&#32467;&#26463;&#26085;&#26399;&#12290;<\/p>\n<h3>&#22522;&#26412;&#27604;&#36739;&#36923;&#36753;<\/h3>\n<p>&#20026;&#20102;&#26816;&#26597;&#37325;&#21472;&#65292;&#25105;&#20204;&#21487;&#20197;&#24212;&#29992;&#19968;&#20010;&#31616;&#21333;&#30340;&#36923;&#36753;&#27979;&#35797;&#65306;&#19968;&#20010;&#33539;&#22260;&#30340;&#24320;&#22987;&#26085;&#26399;&#24517;&#39035;&#26089;&#20110;&#21478;&#19968;&#20010;&#33539;&#22260;&#30340;&#32467;&#26463;&#26085;&#26399;&#65292;&#21516;&#26102;&#23427;&#30340;&#32467;&#26463;&#26085;&#26399;&#20063;&#24517;&#39035;&#26202;&#20110;&#21478;&#19968;&#20010;&#33539;&#22260;&#30340;&#24320;&#22987;&#26085;&#26399;&#12290;&#20197;&#19979;&#26159;&#23454;&#29616;&#27492;&#21151;&#33021;&#30340;&#26041;&#27861;&#65306;<\/p>\n<pre><code>&lt;?php\nfunction dateRangesOverlap($start1, $end1, $start2, $end2) {\n    return ($start1 &lt; $end2) &amp;&amp; ($end1 &gt; $start2);\n}\n?&gt;<\/code><\/pre>\n<h3>&#25552;&#39640;&#21487;&#35835;&#24615;&#65306;&#20351;&#29992;DateTime<\/h3>\n<p>PHP&#30340;<code>DateTime<\/code>&#31867;&#20351;&#24471;&#22788;&#29702;&#26085;&#26399;&#26356;&#21152;&#23481;&#26131;&#12290;&#20197;&#19979;&#26159;&#25913;&#36827;&#21518;&#30340;&#31034;&#20363;&#65292;&#20351;&#29992;&#20102;&#20197;&#19979;&#20195;&#30721;&#65306;<code>DateTime<\/code>&#65306;<\/p>\n<pre><code>&lt;?php\nfunction dateRangesOverlap($start1, $end1, $start2, $end2) {\n    $start1 = new DateTime($start1);\n    $end1 = new DateTime($end1);\n    $start2 = new DateTime($start2);\n    $end2 = new DateTime($end2);\n\n    return ($start1 &lt; $end2) &amp;&amp; ($end1 &gt; $start2);\n}\n?&gt;<\/code><\/pre>\n<h2>&#22788;&#29702;&#36793;&#32536;&#24773;&#20917;<\/h2>\n<p>&#23454;&#38469;&#19978;&#65292;&#20320;&#38656;&#35201;&#32771;&#34385;&#21253;&#21547;&#21644;&#25490;&#38500;&#30340;&#26085;&#26399;&#33539;&#22260;&#65292;&#20854;&#20013;&#26085;&#26399;&#21306;&#38388;&#21487;&#33021;&#21253;&#25324;&#25110;&#19981;&#21253;&#25324;&#20854;&#24320;&#22987;&#25110;&#32467;&#26463;&#26085;&#26399;&#12290;&#36825;&#38656;&#35201;&#26356;&#31934;&#32454;&#30340;&#36923;&#36753;&#23454;&#29616;&#12290;&#20197;&#19979;&#20989;&#25968;&#32771;&#34385;&#20102;&#21253;&#21547;&#21644;&#25490;&#38500;&#37325;&#21472;&#30340;&#24773;&#20917;&#65306;<\/p>\n<pre><code>&lt;?php\nfunction dateRangesOverlap($start1, $end1, $start2, $end2, $inclusive = true) {\n    \/\/ Convert strings to DateTime objects\n    $start1 = new DateTime($start1);\n    $end1 = new DateTime($end1);\n    $start2 = new DateTime($start2);\n    $end2 = new DateTime($end2);\n\n    \/\/ If end date is before the start date we assume an empty range\n    if ($end1 &lt; $start1 || $end2 &lt; $start2) {\n        return false;\n    }\n\n    \/\/ Use different comparison based on inclusiveness\n    if ($inclusive) {\n        return ($start1 &lt;= $end2) &amp;&amp; ($end1 &gt;= $start2);\n    } else {\n        return ($start1 &lt; $end2) &amp;&amp; ($end1 &gt; $start2);\n    }\n}\n?&gt;<\/code><\/pre>\n<h2>&#32771;&#34385;&#26102;&#21306;&#38382;&#39064;&#12290;<\/h2>\n<p>&#22312;&#22788;&#29702;&#19981;&#21516;&#26102;&#21306;&#30340;&#24773;&#20917;&#19979;&#65292;&#25105;&#20204;&#24517;&#39035;&#22312;&#25191;&#34892;&#27604;&#36739;&#20043;&#21069;&#23545;&#26085;&#26399;&#36827;&#34892;&#29305;&#27530;&#36716;&#25442;&#21040;&#19968;&#20010;&#20849;&#21516;&#30340;&#26102;&#21306;&#12290;&#20197;&#19979;&#31034;&#20363;&#23637;&#31034;&#20102;&#22914;&#20309;&#35843;&#25972;&#20197;&#36866;&#24212;&#26102;&#21306;&#65306;<\/p>\n<pre><code>&lt;?php\nfunction dateRangesOverlap($start1, $end1, $start2, $end2, $timezone = NULL) {\n    \/\/ Set default timezone\n    $defaultTz = new DateTimeZone($timezone ?: date_default_timezone_get());\n    \/\/ Convert strings to DateTime objects\n    $start1 = new DateTime($start1, $defaultTz);\n    $end1 = new DateTime($end1, $defaultTz);\n    $start2 = new DateTime($start2, $defaultTz);\n    $end2 = new DateTime($end2, $defaultTz);\n\n    return ($start1 &lt; $end2) &amp;&amp; ($end1 &gt; $start2);\n}\n?&gt;<\/code><\/pre>\n<h2>&#24615;&#33021;&#32771;&#34385;&#22240;&#32032;<\/h2>\n<p>&#23545;&#20110;&#36827;&#34892;&#22823;&#37327;&#26085;&#26399;&#35745;&#31639;&#30340;&#31995;&#32479;&#65292;&#24615;&#33021;&#20248;&#21270;&#33267;&#20851;&#37325;&#35201;&#12290;&#20320;&#21487;&#20197;&#32771;&#34385;&#32531;&#23384;DateTime&#23545;&#35937;&#30340;&#21019;&#24314;&#65292;&#36991;&#20813;&#19981;&#24517;&#35201;&#30340;&#26102;&#21306;&#36716;&#25442;&#65292;&#24182;&#20351;&#29992;&#22914;Xdebug&#36719;&#20214;&#36825;&#26679;&#30340;&#22522;&#20934;&#27979;&#35797;&#24037;&#20855;&#26469; profiling &#20195;&#30721;&#12290;<\/p>\n<h2>&#25688;&#35201;<\/h2>\n<p>&#36825;&#20010;&#25945;&#31243;&#23637;&#31034;&#20102;&#22914;&#20309;&#20351;&#29992;PHP&#26816;&#26597;&#37325;&#21472;&#30340;&#26085;&#26399;&#33539;&#22260;&#12290;&#25105;&#20204;&#25506;&#35752;&#20102;&#22810;&#31181;&#26041;&#27861;&#65292;&#20174;&#22522;&#26412;&#30340;&#36923;&#36753;&#27604;&#36739;&#21040;&#26356;&#22797;&#26434;&#30340;&#26102;&#21306;&#32771;&#34385;&#22240;&#32032;&#12290;&#36825;&#20123;&#31574;&#30053;&#23545;&#20110;&#26500;&#24314;&#39640;&#25928;&#22788;&#29702;&#26085;&#26399;&#21644;&#26102;&#38388;&#30340;&#24212;&#29992;&#31243;&#24207;&#33267;&#20851;&#37325;&#35201;&#12290;<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#20171;&#32461; &#22312;&#22788;&#29702;&#25490;&#26399;&#12289;&#39044;&#35746;&#25110;&#20854;&#20182;&#28041;&#21450;&#26102;&#38388;&#33539;&#22260;&#038;#30340..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[38],"tuisongtax":[],"class_list":["post-462","my1js","type-my1js","status-publish","hentry","my1js2nav-jcyy"],"acf":{"qian_art_seotitle":"","qian_art_seotitle_source":{"label":"SEO\u6807\u9898","type":"text","formatted_value":""},"qian_art_seokws":"","qian_art_seokws_source":{"label":"SEO\u5173\u952e\u8bcd","type":"text","formatted_value":""},"qian_art_stzhong":"","qian_art_stzhong_source":{"label":"\u4e2d | \u77ed\u6807\u9898","type":"text","formatted_value":""}},"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js\/462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/types\/my1js"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/media?parent=462"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=462"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=462"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}