1. <big id="rnq4s"><thead id="rnq4s"></thead></big>
      <ol id="rnq4s"><dfn id="rnq4s"></dfn></ol>
    2. <source id="rnq4s"><ul id="rnq4s"></ul></source><sup id="rnq4s"></sup>
      \n border=\"1\" style=\"width: 80%;\">\n \n \n \n {% for product in products %}\n \n
      Product<\/td>\n Description<\/td>\n Value<\/td>\n Date<\/td>\n <\/tr>\n <\/thead>\n
      {{ product.name }}<\/td>\n {{ product.description }}<\/td>\n {{ product.value }}<\/td>\n {{ product.date_register|date(\"m\/d\/Y\") }}<\/td>\n <\/tr>\n {% endfor %}\n <\/tbody>\n <\/table>\n <\/body>\n<\/html><\/pre>\n

      此時,我們?nèi)匀粨碛邢嗤捻撁妫覀兺ㄟ^分離上下文塊來降低了它的複雜性。 <\/p>\n

      緩存<\/strong><\/p>

      Environment<\/code>對像不僅可以用於加載模板。如果我們使用關(guān)聯(lián)目錄的cache<\/code>選項傳遞,Twig將緩存編譯後的模板,從而避免在後續(xù)請求中解析模板。編譯後的模板將存儲在我們提供的目錄中。請注意,這是編譯模板的緩存,而不是已評估的模板的緩存。這意味著Twig將解析、編譯並保存模板文件。所有後續(xù)請求仍然需要評估模板,但第一步已經(jīng)為您完成。讓我們通過編輯bootstrap.php<\/code>文件來緩存示例中的模板:<\/p>\n

       Hello \" . $name . \"<\/p>\"; ?><\/pre>\n

      (以下內(nèi)容與原文類似,但做了部分語句調(diào)整和段落劃分,並保持了圖片位置不變)<\/strong><\/p>\n

      循環(huán)<\/strong><\/p>\n

      在我們的示例中,我們已經(jīng)看到瞭如何使用Twig進行循環(huán)。基本上,我們使用for<\/code>標籤並為指定數(shù)組中的每個元素分配一個別名。在本例中,我們?yōu)?code>products<\/code>數(shù)組分配了別名product<\/code>。之後,我們可以使用.<\/code>運算符訪問每個數(shù)組元素中的所有屬性。我們使用endfor<\/code>標籤來指示循環(huán)的結(jié)束。我們還可以使用..<\/code>運算符循環(huán)遍歷數(shù)字或字母。如下所示:<\/p>\n

      Hello {{ name }}<\/p><\/pre>\n

      或字母:<\/p>\n

      composer require twig\/twig<\/pre>\n

      此運算符只是range<\/code>函數(shù)的語法糖,其工作方式與本機PHPrange<\/code>函數(shù)相同。同樣有用的選項是向循環(huán)添加條件。使用條件,我們可以過濾要迭代的元素。假設(shè)我們想要迭代所有值小於250的產(chǎn)品:<\/p>\n

      \n

      條件語句<\/strong><\/p>\n

      Twig還以if<\/code>、elseif<\/code>、if not<\/code>和else<\/code>標籤的形式提供條件語句。就像在任何編程語言中一樣,我們可以使用這些標籤來過濾模板中的條件。假設(shè)在我們的示例中,我們只想顯示值高於500的產(chǎn)品:<\/p>\n

       'Notebook',\n        'description'   => 'Core i7',\n        'value'         =>  800.00,\n        'date_register' => '2017-06-22',\n    ],\n    [\n        'name'          => 'Mouse',\n        'description'   => 'Razer',\n        'value'         =>  125.00,\n        'date_register' => '2017-10-25',\n    ],\n    [\n        'name'          => 'Keyboard',\n        'description'   => 'Mechanical Keyboard',\n        'value'         =>  250.00,\n        'date_register' => '2017-06-23',\n    ],\n];\n\n\/\/ 渲染我們的視圖\necho $twig->render('index.html', ['products' => $products] );<\/pre>\n

      過濾器<\/strong><\/p>\n

      過濾器允許我們過濾傳遞給模板的信息以及顯示信息的格式。讓我們看看一些最常用和最重要的過濾器。 Twig過濾器的完整列表可以在這裡找到。 <\/p>\n

      日期和date_modify<\/code><\/h3>\n

      date<\/code>過濾器將日期格式化為給定格式。正如我們在示例中看到的:<\/p>\n

      \n\n    \n        \n        Twig Example<\/title>\n    <\/head>\n    <body>
      <h1><a href="http://miracleart.cn/">国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂</a></h1>\n    <table> border=\"1\" style=\"width: 80%;\">\n        <thead>\n            <tr>\n                <td>Product<\/td>\n                <td>Description<\/td>\n                <td>Value<\/td>\n                <td>Date<\/td>\n            <\/tr>\n        <\/thead>\n        <tbody>\n            {% for product in products %}\n                <tr>\n                    <td>{{ product.name }}<\/td>\n                    <td>{{ product.description }}<\/td>\n                    <td>{{ product.value }}<\/td>\n                    <td>{{ product.date_register|date(\"m\/d\/Y\") }}<\/td>\n                <\/tr>\n            {% endfor %}\n        <\/tbody>\n    <\/table>\n    <\/body>\n<\/html><\/pre>\n<p>我們以月\/日\/年的格式顯示日期。除了<code>date<\/code>過濾器之外,我們還可以使用修飾符字符串使用<code>date_modify<\/code>過濾器更改日期。例如,如果我們想向日期添加一天,我們可以使用以下內(nèi)容:<\/p>\n<pre class='brush:php;toolbar:false;'><!DOCTYPE html>\n<html lang=\"pt-BR\">\n    <head>\n        <meta charset=\"UTF-8\">\n        <title>Tutorial Example<\/title>\n    <\/head>\n    <body>\n        {% block content %}\n        {% endblock %}\n    <\/body>\n<\/html><\/pre>\n<h3><code>format<\/code><\/h3>\n<p>通過替換所有佔位符來格式化給定字符串。例如:<\/p>\n<pre class='brush:php;toolbar:false;'>{% extends \"layout.html\" %}\n\n{% block content %}\n    <table> border=\"1\" style=\"width: 80%;\">\n        <thead>\n            <tr>\n                <td>Product<\/td>\n                <td>Description<\/td>\n                <td>Value<\/td>\n                <td>Date<\/td>\n            <\/tr>\n        <\/thead>\n        <tbody>\n            {% for product in products %}\n                <tr>\n                    <td>{{ product.name }}<\/td>\n                    <td>{{ product.description }}<\/td>\n                    <td>{{ product.value }}<\/td>\n                    <td>{{ product.date_register|date(\"m\/d\/Y\") }}<\/td>\n                <\/tr>\n            {% endfor %}\n        <\/tbody>\n    <\/table>\n{% endblock %}<\/pre>\n<h3><code>striptags<\/code><\/h3>\n<p><code>striptags<\/code>過濾器去除SGML\/XML標籤,並將相鄰的空格替換為空格:<\/p><pre class='brush:php;toolbar:false;'><?php echo \"<p> Hello \" . $name . \"<\/p>\"; ?><\/pre>\n<h3><code>escape<\/code><\/h3>\n<p><code>escape<\/code>是最重要的過濾器之一。它過濾字符串以安全地插入最終輸出中。默認情況下,它使用HTML轉(zhuǎn)義策略,因此<\/p>\n<pre class='brush:php;toolbar:false;'><p>Hello {{ name }}<\/p><\/pre>\n<p>等效於<\/p>\n<pre class='brush:php;toolbar:false;'>composer require twig\/twig<\/pre>\n<p><code>js<\/code>、<code>css<\/code>、<code>url<\/code>和<code>html_attr<\/code>轉(zhuǎn)義策略也可使用。它們分別為Javascript、CSS、URI和HTML屬性上下文轉(zhuǎn)義字符串。 <\/p>\n<p><strong>調(diào)試<\/strong><\/p>\n<p>最後,讓我們來看看調(diào)試。有時我們需要訪問模板變量的所有信息。為此,Twig具有<code>dump()<\/code>函數(shù)。此函數(shù)默認情況下不可用。在創(chuàng)建Twig環(huán)境時,我們必須添加<code>Twig_Extension_Debug<\/code>擴展:<\/p>\n<pre class='brush:php;toolbar:false;'><?php\n\/\/ 加載我們的自動加載器\nrequire_once __DIR__.'\/vendor\/autoload.php';\n\n\/\/ 指定我們的Twig模板位置\n$loader = new Twig_Loader_Filesystem(__DIR__.'\/templates');\n\n\/\/ 實例化我們的Twig\n$twig = new Twig_Environment($loader);<\/pre>\n<p>此步驟是必要的,這樣我們才不會意外地在生產(chǎn)服務(wù)器上洩露調(diào)試信息。配置完成後,我們只需使用<code>dump()<\/code>函數(shù)即可轉(zhuǎn)儲有關(guān)模板變量的所有信息。 <\/p>\n<pre class='brush:php;toolbar:false;'><?php\nrequire_once __DIR__.'\/bootstrap.php';\n\n\/\/ 創(chuàng)建產(chǎn)品列表\n$products = [\n    [\n        'name'          => 'Notebook',\n        'description'   => 'Core i7',\n        'value'         =>  800.00,\n        'date_register' => '2017-06-22',\n    ],\n    [\n        'name'          => 'Mouse',\n        'description'   => 'Razer',\n        'value'         =>  125.00,\n        'date_register' => '2017-10-25',\n    ],\n    [\n        'name'          => 'Keyboard',\n        'description'   => 'Mechanical Keyboard',\n        'value'         =>  250.00,\n        'date_register' => '2017-06-23',\n    ],\n];\n\n\/\/ 渲染我們的視圖\necho $twig->render('index.html', ['products' => $products] );<\/pre>\n<p><strong>結(jié)論<\/strong><\/p>\n<p>希望本文能為您提供Twig基礎(chǔ)知識的堅實基礎(chǔ),並立即啟動您的項目!如果您想更深入地了解Twig,官方網(wǎng)站提供了您可以查閱的非常好的文檔和參考。您使用模板引擎嗎?您對Twig有什麼看法?您會將它與Blade或Smarty等流行的替代方案進行比較嗎? <\/p>\n<p><strong>(以下內(nèi)容為FAQ,原文已包含,此處略去)<\/strong><\/p>"}	</script>
      	
      <meta http-equiv="Cache-Control" content="no-transform" />
      <meta http-equiv="Cache-Control" content="no-siteapp" />
      <script>var V_PATH="/";window.onerror=function(){ return true; };</script>
      </head>
      
      <body data-commit-time="2023-12-28T14:50:12+08:00" class="editor_body body2_2">
      	<link rel="stylesheet" type="text/css" href="/static/csshw/stylehw.css">
      <header>
          <div   id="377j5v51b"   class="head">
              <div   id="377j5v51b"   class="haed_left">
                  <div   id="377j5v51b"   class="haed_logo">
                      <a href="http://miracleart.cn/zh-tw/" title="" class="haed_logo_a">
                          <img src="/static/imghw/logo.png" alt="" class="haed_logoimg">
                      </a>
                  </div>
                  <div   id="377j5v51b"   class="head_nav">
                      <div   id="377j5v51b"   class="head_navs">
                          <a href="javascript:;" title="社群" class="head_nava head_nava-template1">社群</a>
                          <div   class="377j5v51b"   id="dropdown-template1" style="display: none;">
                              <div   id="377j5v51b"   class="languagechoose">
                                  <a href="http://miracleart.cn/zh-tw/article.html" title="文章" class="languagechoosea on">文章</a>
                                  <a href="http://miracleart.cn/zh-tw/faq/zt" title="合集" class="languagechoosea">合集</a>
                                  <a href="http://miracleart.cn/zh-tw/wenda.html" title="問答" class="languagechoosea">問答</a>
                              </div>
                          </div>
                      </div>
      
                      <div   id="377j5v51b"   class="head_navs">
                          <a href="javascript:;" title="學(xué)習(xí)" class="head_nava head_nava-template1_1">學(xué)習(xí)</a>
                          <div   class="377j5v51b"   id="dropdown-template1_1" style="display: none;">
                              <div   id="377j5v51b"   class="languagechoose">
                                  <a href="http://miracleart.cn/zh-tw/course.html" title="課程" class="languagechoosea on">課程</a>
                                  <a href="http://miracleart.cn/zh-tw/dic/" title="程式設(shè)計字典" class="languagechoosea">程式設(shè)計字典</a>
                              </div>
                          </div>
                      </div>
      
                      <div   id="377j5v51b"   class="head_navs">
                          <a href="javascript:;" title="工具庫" class="head_nava head_nava-template1_2">工具庫</a>
                          <div   class="377j5v51b"   id="dropdown-template1_2" style="display: none;">
                              <div   id="377j5v51b"   class="languagechoose">
                                  <a href="http://miracleart.cn/zh-tw/toolset/development-tools" title="開發(fā)工具" class="languagechoosea on">開發(fā)工具</a>
                                  <a href="http://miracleart.cn/zh-tw/toolset/website-source-code" title="網(wǎng)站源碼" class="languagechoosea">網(wǎng)站源碼</a>
                                  <a href="http://miracleart.cn/zh-tw/toolset/php-libraries" title="PHP 函式庫" class="languagechoosea">PHP 函式庫</a>
                                  <a href="http://miracleart.cn/zh-tw/toolset/js-special-effects" title="JS特效" class="languagechoosea on">JS特效</a>
                                  <a href="http://miracleart.cn/zh-tw/toolset/website-materials" title="網(wǎng)站素材" class="languagechoosea on">網(wǎng)站素材</a>
                                  <a href="http://miracleart.cn/zh-tw/toolset/extension-plug-ins" title="擴充插件" class="languagechoosea on">擴充插件</a>
                              </div>
                          </div>
                      </div>
      
                      <div   id="377j5v51b"   class="head_navs">
                          <a href="http://miracleart.cn/zh-tw/ai" title="AI工具" class="head_nava head_nava-template1_3">AI工具</a>
                      </div>
      
                      <div   id="377j5v51b"   class="head_navs">
                          <a href="javascript:;" title="休閒" class="head_nava head_nava-template1_3">休閒</a>
                          <div   class="377j5v51b"   id="dropdown-template1_3" style="display: none;">
                              <div   id="377j5v51b"   class="languagechoose">
                                  <a href="http://miracleart.cn/zh-tw/game" title="遊戲下載" class="languagechoosea on">遊戲下載</a>
                                  <a href="http://miracleart.cn/zh-tw/mobile-game-tutorial/" title="遊戲教程" class="languagechoosea">遊戲教程</a>
      
                              </div>
                          </div>
                      </div>
                  </div>
              </div>
                          <div   id="377j5v51b"   class="head_search">
                      <input id="key_words"  onkeydown="if (event.keyCode == 13) searchs('zh-tw')" class="search-input" type="text" autocomplete="off" name="keywords" required="required" placeholder="Block,address,transaction,news" value="">
                      <a href="javascript:;" title="搜尋"  onclick="searchs('zh-tw')"><img src="/static/imghw/find.png" alt="搜尋"></a>
                  </div>
                      <div   id="377j5v51b"   class="head_right">
                  <div   id="377j5v51b"   class="haed_language">
                      <a href="javascript:;" class="layui-btn haed_language_btn">繁體中文<i class="layui-icon layui-icon-triangle-d"></i></a>
                      <div   class="377j5v51b"   id="dropdown-template" style="display: none;">
                          <div   id="377j5v51b"   class="languagechoose">
                                                      <a href="javascript:setlang('zh-cn');" title="簡體中文" class="languagechoosea">簡體中文</a>
                                                      <a href="javascript:setlang('en');" title="English" class="languagechoosea">English</a>
                                                      <a href="javascript:;" title="繁體中文" class="languagechoosea">繁體中文</a>
                                                      <a href="javascript:setlang('ja');" title="日本語" class="languagechoosea">日本語</a>
                                                      <a href="javascript:setlang('ko');" title="???" class="languagechoosea">???</a>
                                                      <a href="javascript:setlang('ms');" title="Melayu" class="languagechoosea">Melayu</a>
                                                      <a href="javascript:setlang('fr');" title="Fran?ais" class="languagechoosea">Fran?ais</a>
                                                      <a href="javascript:setlang('de');" title="Deutsch" class="languagechoosea">Deutsch</a>
                                                  </div>
                      </div>
                  </div>
                  <span id="377j5v51b"    class="head_right_line"></span>
                                  <div style="display: block;" id="login" class="haed_login ">
                          <a href="javascript:;"  title="Login" class="haed_logina ">Login</a>
                      </div>
                      <div style="display: block;" id="reg" class="head_signup login">
                          <a href="javascript:;"  title="singup" class="head_signupa">singup</a>
                      </div>
                  
              </div>
          </div>
      </header>
      
      	
      	<main>
      		<div   id="377j5v51b"   class="Article_Details_main">
      			<div   id="377j5v51b"   class="Article_Details_main1">
      							<div   id="377j5v51b"   class="Article_Details_main1L">
      					<div   id="377j5v51b"   class="Article_Details_main1Lmain" id="Article_Details_main1Lmain">
      						<div   id="377j5v51b"   class="Article_Details_main1L1">目錄</div>
      						<div   id="377j5v51b"   class="Article_Details_main1L2" id="Article_Details_main1L2">
      							<!-- 左側(cè)懸浮,文章定位標題1 id="Article_Details_main1L2s_1"-->
      															<div   id="377j5v51b"   class="Article_Details_main1L2s ">
      									<a href="#日期和-code-date-modify-code" title="日期和<code>date_modify</code>" >日期和<code>date_modify</code></a>
      								</div>
      																<div   id="377j5v51b"   class="Article_Details_main1L2s ">
      									<a href="#code-format-code" title="<code>format</code>" ><code>format</code></a>
      								</div>
      																<div   id="377j5v51b"   class="Article_Details_main1L2s ">
      									<a href="#code-striptags-code" title="<code>striptags</code>" ><code>striptags</code></a>
      								</div>
      																<div   id="377j5v51b"   class="Article_Details_main1L2s ">
      									<a href="#code-escape-code" title="<code>escape</code>" ><code>escape</code></a>
      								</div>
      														</div>
      					</div>
      				</div>
      							<div   id="377j5v51b"   class="Article_Details_main1M">
      					<div   id="377j5v51b"   class="phpgenera_Details_mainL1">
      						<a href="http://miracleart.cn/zh-tw/" title="首頁"
      							class="phpgenera_Details_mainL1a">首頁</a>
      						<img src="/static/imghw/top_right.png" alt="" />
      												<a href="http://miracleart.cn/zh-tw/be/"
      							class="phpgenera_Details_mainL1a">後端開發(fā)</a>
      						<img src="/static/imghw/top_right.png" alt="" />
      												<a href="http://miracleart.cn/zh-tw/php-weizijiaocheng.html"
      							class="phpgenera_Details_mainL1a">php教程</a>
      						<img src="/static/imghw/top_right.png" alt="" />
      						<span>樹枝 - 最受歡迎的獨立PHP模板引擎</span>
      					</div>
      					
      					<div   id="377j5v51b"   class="Articlelist_txts">
      						<div   id="377j5v51b"   class="Articlelist_txts_info">
      							<h1 class="Articlelist_txts_title">樹枝 - 最受歡迎的獨立PHP模板引擎</h1>
      							<div   id="377j5v51b"   class="Articlelist_txts_info_head">
      								<div   id="377j5v51b"   class="author_info">
      									<a href="http://miracleart.cn/zh-tw/member/1468493.html"  class="author_avatar">
      									<img class="lazy"  data-src="https://img.php.cn/upload/avatar/000/000/001/66ea8139b1640968.png" src="/static/imghw/default1.png" alt="Lisa Kudrow">
      									</a>
      									<div   id="377j5v51b"   class="author_detail">
      																			<a href="http://miracleart.cn/zh-tw/member/1468493.html" class="author_name">Lisa Kudrow</a>
                                      										</div>
      								</div>
                      			</div>
      							<span id="377j5v51b"    class="Articlelist_txts_time">Feb 09, 2025 am	 09:07 AM</span>
      														
      						</div>
      					</div>
      					<hr />
      					<div   id="377j5v51b"   class="article_main php-article">
      						<div   id="377j5v51b"   class="article-list-left detail-content-wrap content">
      						<ins class="adsbygoogle"
      							style="display:block; text-align:center;"
      							data-ad-layout="in-article"
      							data-ad-format="fluid"
      							data-ad-client="ca-pub-5902227090019525"
      							data-ad-slot="3461856641">
      						</ins>
      						
      
      					<p><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/173906323392943.jpg" class="lazy" alt="Twig - the Most Popular Stand-Alone PHP Template Engine "></p>
      <p><strong>Twig:一款流行的PHP模板引擎</strong></p>
      <p>Twig是由Sensio Labs開發(fā)的PHP流行模板引擎,它簡化了PHP代碼,並增加了安全和調(diào)試等功能。 Twig同時作用於項目的frontend和backend,可以從兩個角度來看:模板設(shè)計師的Twig和開發(fā)者的Twig。 Twig使用名為<code>Environment</code>的核心對象來存儲配置、擴展,並從文件系統(tǒng)或其他位置加載模板。 Twig支持嵌套模板(塊),避免模板中元素重複,並能緩存編譯後的模板以加快後續(xù)請求速度。 Twig支持條件語句、循環(huán)和過濾器來控制模板中信息的顯示,並提供調(diào)試功能來轉(zhuǎn)儲模板變量的所有信息。 </p>
      <p><em>本文由Wern Ancheta同行評審。感謝所有SitePoint的同行評審員,使SitePoint的內(nèi)容達到最佳狀態(tài)!</em></p>
      <hr>
      <p>Twig是PHP的模板引擎。但是,PHP本身不是模板引擎嗎?是的,也不是!儘管PHP最初是作為模板引擎,但它的發(fā)展並非如此,雖然我們?nèi)匀豢梢詫⑵溆米髂0逡?,請問您更喜歡哪個版本的“Hello world”:</p>
      <pre class='brush:php;toolbar:false;'><?php echo "<p> Hello " . $name . "</p>"; ?></pre>
      <p>還是</p>
      <pre class='brush:php;toolbar:false;'><p>Hello {{ name }}</p></pre>
      <p>PHP是一種冗長的語言,在嘗試輸出HTML內(nèi)容時,這種冗長性會被放大?,F(xiàn)代模板系統(tǒng)將消除部分冗長性,並在其之上增加相當多的功能。諸如安全和調(diào)試功能之類的特性是現(xiàn)代模板引擎的支柱。今天,我們將重點介紹Twig。 </p>
      <p><img src="/static/imghw/default1.png"  data-src="https://img.php.cn/upload/article/000/000/000/173906323392943.jpg"  class="lazy" alt="Twig - the Most Popular Stand-Alone PHP Template Engine " /></p>
      <p>Twig是由Sensio Labs(Blackfire和Symfony的開發(fā)公司)創(chuàng)建的模板引擎。讓我們來看看它的主要優(yōu)勢以及如何在項目中使用它。 </p>
      <p><strong>安裝</strong></p>
      <p>安裝Twig有兩種方法。我們可以使用其網(wǎng)站上提供的tar包,或者像我們一直做的那樣,使用Composer。 </p>
      <pre class='brush:php;toolbar:false;'>composer require twig/twig</pre>
      <p><em>我們假設(shè)您正在運行已設(shè)置PHP並全局安裝Composer的環(huán)境。最好的方法是使用Homestead Improved——它可以讓您在5分鐘內(nèi)在與我們使用的完全相同的機器上開始使用,這樣我們就能在同一頁面上。如果您想了解有關(guān)PHP環(huán)境的更多信息,我們這裡有一本關(guān)於此的優(yōu)秀付費書籍可供購買。 </em></p>
      <p>在我們繼續(xù)之前,我們需要先澄清一些事情。作為模板引擎,Twig同時作用於項目的frontend和backend。因此,我們可以從兩個不同的角度來看待Twig:模板設(shè)計師的Twig和開發(fā)者的Twig。一方面,我們準備所有需要的數(shù)據(jù);另一方面,我們呈現(xiàn)所有這些數(shù)據(jù)。 </p>
      <p><strong>基本用法</strong></p><p>為了舉例說明Twig的基本用法,讓我們創(chuàng)建一個簡單的項目。首先,我們需要引導(dǎo)Twig。讓我們創(chuàng)建一個包含以下內(nèi)容的<code>bootstrap.php</code>文件:</p>
      <pre class='brush:php;toolbar:false;'><?php echo "<p> Hello " . $name . "</p>"; ?></pre>
      <p>Twig使用名為<code>Environment</code>的核心對象。此類的實例用於存儲配置、擴展,並從文件系統(tǒng)或其他位置加載模板。在我們的Twig實例引導(dǎo)後,我們可以繼續(xù)創(chuàng)建一個<code>index.php</code>文件,在其中加載一些數(shù)據(jù)並將其傳遞給Twig模板。 </p>
      <pre class='brush:php;toolbar:false;'><p>Hello {{ name }}</p></pre>
      <p>這是一個簡單的示例;我們正在創(chuàng)建一個包含產(chǎn)品的數(shù)組,例如我們的機械鍵盤,我們可以在模板中使用它。然後,我們使用<code>render()</code>方法,它接受模板名稱(這是我們之前定義的模板文件夾中的一個文件)以及我們要傳遞給模板的數(shù)據(jù)。為了完成我們的示例,讓我們進入我們的<code>/templates</code>文件夾並創(chuàng)建一個<code>index.html</code>文件。首先,讓我們看看模板本身。 </p>
      <pre class='brush:php;toolbar:false;'>composer require twig/twig</pre>
      <p>在瀏覽器中打開<code>index.php</code>(訪問localhost或homestead.app,具體取決於您如何設(shè)置主機和服務(wù)器)現(xiàn)在應(yīng)該會顯示以下屏幕:</p>
      <p><img src="/static/imghw/default1.png"  data-src="https://img.php.cn/upload/article/000/000/000/173906323463936.jpg"  class="lazy" alt="Twig - the Most Popular Stand-Alone PHP Template Engine " /></p>
      <p>但是讓我們回到並仔細看看我們的模板代碼。有兩種類型的分隔符:<code>{{ ... }}</code>用於打印表達式或操作的結(jié)果,而<code>{% ... %}</code>用於執(zhí)行諸如條件語句和循環(huán)之類的語句。這些分隔符是Twig的主要語言結(jié)構(gòu),Twig使用它們來“告知”模板它必須呈現(xiàn)Twig元素。 </p>
      <p><strong>(以下內(nèi)容與原文類似,但做了部分語句調(diào)整和段落劃分,並保持了圖片位置不變)</strong></p>
      <p><strong>佈局</strong></p>
      <p>為了避免在模板中重複元素(如頁眉和頁腳),Twig允許我們將模板嵌套在模板中,這些被稱為塊。為了舉例說明這一點,讓我們將實際內(nèi)容與示例中的HTML定義分開。讓我們創(chuàng)建一個新的HTML文件並將其命名為<code>layout.html</code>:</p>
      <pre class='brush:php;toolbar:false;'><?php
      // 加載我們的自動加載器
      require_once __DIR__.'/vendor/autoload.php';
      
      // 指定我們的Twig模板位置
      $loader = new Twig_Loader_Filesystem(__DIR__.'/templates');
      
      // 實例化我們的Twig
      $twig = new Twig_Environment($loader);</pre>
      <p>我們創(chuàng)建了一個名為<code>content</code>的塊。我們的意思是,每個從<code>layout.html</code>擴展的模板都可以實現(xiàn)一個<code>content</code>塊,該塊將顯示在該位置。這樣,我們可以多次重用佈局而無需重寫它。在本例中,<code>index.html</code>文件現(xiàn)在如下所示:</p>
      <pre class='brush:php;toolbar:false;'><?php
      require_once __DIR__.'/bootstrap.php';
      
      // 創(chuàng)建產(chǎn)品列表
      $products = [
          [
              'name'          => 'Notebook',
              'description'   => 'Core i7',
              'value'         =>  800.00,
              'date_register' => '2017-06-22',
          ],
          [
              'name'          => 'Mouse',
              'description'   => 'Razer',
              'value'         =>  125.00,
              'date_register' => '2017-10-25',
          ],
          [
              'name'          => 'Keyboard',
              'description'   => 'Mechanical Keyboard',
              'value'         =>  250.00,
              'date_register' => '2017-06-23',
          ],
      ];
      
      // 渲染我們的視圖
      echo $twig->render('index.html', ['products' => $products] );</pre>
      <p>Twig還允許我們只渲染單個塊。為此,我們需要首先加載模板,然後渲染塊。 </p>
      <pre class='brush:php;toolbar:false;'><!DOCTYPE html>
      <html lang="pt-BR">
          <head>
              <meta charset="UTF-8">
              <title>Twig Example</title>
          </head>
          <body>
          <table> border="1" style="width: 80%;">
              <thead>
                  <tr>
                      <td>Product</td>
                      <td>Description</td>
                      <td>Value</td>
                      <td>Date</td>
                  </tr>
              </thead>
              <tbody>
                  {% for product in products %}
                      <tr>
                          <td>{{ product.name }}</td>
                          <td>{{ product.description }}</td>
                          <td>{{ product.value }}</td>
                          <td>{{ product.date_register|date("m/d/Y") }}</td>
                      </tr>
                  {% endfor %}
              </tbody>
          </table>
          </body>
      </html></pre>
      <p>此時,我們?nèi)匀粨碛邢嗤捻撁妫覀兺ㄟ^分離上下文塊來降低了它的複雜性。 </p>
      <p><strong>緩存</strong></p><p><code>Environment</code>對像不僅可以用於加載模板。如果我們使用關(guān)聯(lián)目錄的<code>cache</code>選項傳遞,Twig將緩存編譯後的模板,從而避免在後續(xù)請求中解析模板。編譯後的模板將存儲在我們提供的目錄中。請注意,這是編譯模板的緩存,而不是已評估的模板的緩存。這意味著Twig將解析、編譯並保存模板文件。所有後續(xù)請求仍然需要評估模板,但第一步已經(jīng)為您完成。讓我們通過編輯<code>bootstrap.php</code>文件來緩存示例中的模板:</p>
      <pre class='brush:php;toolbar:false;'><?php echo "<p> Hello " . $name . "</p>"; ?></pre>
      <p><strong>(以下內(nèi)容與原文類似,但做了部分語句調(diào)整和段落劃分,並保持了圖片位置不變)</strong></p>
      <p><strong>循環(huán)</strong></p>
      <p>在我們的示例中,我們已經(jīng)看到瞭如何使用Twig進行循環(huán)?;旧?,我們使用<code>for</code>標籤並為指定數(shù)組中的每個元素分配一個別名。在本例中,我們?yōu)?code>products</code>數(shù)組分配了別名<code>product</code>。之後,我們可以使用<code>.</code>運算符訪問每個數(shù)組元素中的所有屬性。我們使用<code>endfor</code>標籤來指示循環(huán)的結(jié)束。我們還可以使用<code>..</code>運算符循環(huán)遍歷數(shù)字或字母。如下所示:</p>
      <pre class='brush:php;toolbar:false;'><p>Hello {{ name }}</p></pre>
      <p>或字母:</p>
      <pre class='brush:php;toolbar:false;'>composer require twig/twig</pre>
      <p>此運算符只是<code>range</code>函數(shù)的語法糖,其工作方式與本機PHP<code>range</code>函數(shù)相同。同樣有用的選項是向循環(huán)添加條件。使用條件,我們可以過濾要迭代的元素。假設(shè)我們想要迭代所有值小於250的產(chǎn)品:</p>
      <pre class='brush:php;toolbar:false;'><?php
      // 加載我們的自動加載器
      require_once __DIR__.'/vendor/autoload.php';
      
      // 指定我們的Twig模板位置
      $loader = new Twig_Loader_Filesystem(__DIR__.'/templates');
      
      // 實例化我們的Twig
      $twig = new Twig_Environment($loader);</pre>
      <p><strong>條件語句</strong></p>
      <p>Twig還以<code>if</code>、<code>elseif</code>、<code>if not</code>和<code>else</code>標籤的形式提供條件語句。就像在任何編程語言中一樣,我們可以使用這些標籤來過濾模板中的條件。假設(shè)在我們的示例中,我們只想顯示值高於500的產(chǎn)品:</p>
      <pre class='brush:php;toolbar:false;'><?php
      require_once __DIR__.'/bootstrap.php';
      
      // 創(chuàng)建產(chǎn)品列表
      $products = [
          [
              'name'          => 'Notebook',
              'description'   => 'Core i7',
              'value'         =>  800.00,
              'date_register' => '2017-06-22',
          ],
          [
              'name'          => 'Mouse',
              'description'   => 'Razer',
              'value'         =>  125.00,
              'date_register' => '2017-10-25',
          ],
          [
              'name'          => 'Keyboard',
              'description'   => 'Mechanical Keyboard',
              'value'         =>  250.00,
              'date_register' => '2017-06-23',
          ],
      ];
      
      // 渲染我們的視圖
      echo $twig->render('index.html', ['products' => $products] );</pre>
      <p><strong>過濾器</strong></p>
      <p>過濾器允許我們過濾傳遞給模板的信息以及顯示信息的格式。讓我們看看一些最常用和最重要的過濾器。 Twig過濾器的完整列表可以在這裡找到。 </p>
      <h3 id="日期和-code-date-modify-code">日期和<code>date_modify</code></h3>
      <p><code>date</code>過濾器將日期格式化為給定格式。正如我們在示例中看到的:</p>
      <pre class='brush:php;toolbar:false;'><!DOCTYPE html>
      <html lang="pt-BR">
          <head>
              <meta charset="UTF-8">
              <title>Twig Example</title>
          </head>
          <body>
          <table> border="1" style="width: 80%;">
              <thead>
                  <tr>
                      <td>Product</td>
                      <td>Description</td>
                      <td>Value</td>
                      <td>Date</td>
                  </tr>
              </thead>
              <tbody>
                  {% for product in products %}
                      <tr>
                          <td>{{ product.name }}</td>
                          <td>{{ product.description }}</td>
                          <td>{{ product.value }}</td>
                          <td>{{ product.date_register|date("m/d/Y") }}</td>
                      </tr>
                  {% endfor %}
              </tbody>
          </table>
          </body>
      </html></pre>
      <p>我們以月/日/年的格式顯示日期。除了<code>date</code>過濾器之外,我們還可以使用修飾符字符串使用<code>date_modify</code>過濾器更改日期。例如,如果我們想向日期添加一天,我們可以使用以下內(nèi)容:</p>
      <pre class='brush:php;toolbar:false;'><!DOCTYPE html>
      <html lang="pt-BR">
          <head>
              <meta charset="UTF-8">
              <title>Tutorial Example</title>
          </head>
          <body>
              {% block content %}
              {% endblock %}
          </body>
      </html></pre>
      <h3 id="code-format-code"><code>format</code></h3>
      <p>通過替換所有佔位符來格式化給定字符串。例如:</p>
      <pre class='brush:php;toolbar:false;'>{% extends "layout.html" %}
      
      {% block content %}
          <table> border="1" style="width: 80%;">
              <thead>
                  <tr>
                      <td>Product</td>
                      <td>Description</td>
                      <td>Value</td>
                      <td>Date</td>
                  </tr>
              </thead>
              <tbody>
                  {% for product in products %}
                      <tr>
                          <td>{{ product.name }}</td>
                          <td>{{ product.description }}</td>
                          <td>{{ product.value }}</td>
                          <td>{{ product.date_register|date("m/d/Y") }}</td>
                      </tr>
                  {% endfor %}
              </tbody>
          </table>
      {% endblock %}</pre>
      <h3 id="code-striptags-code"><code>striptags</code></h3>
      <p><code>striptags</code>過濾器去除SGML/XML標籤,並將相鄰的空格替換為空格:</p><pre class='brush:php;toolbar:false;'><?php echo "<p> Hello " . $name . "</p>"; ?></pre>
      <h3 id="code-escape-code"><code>escape</code></h3>
      <p><code>escape</code>是最重要的過濾器之一。它過濾字符串以安全地插入最終輸出中。默認情況下,它使用HTML轉(zhuǎn)義策略,因此</p>
      <pre class='brush:php;toolbar:false;'><p>Hello {{ name }}</p></pre>
      <p>等效於</p>
      <pre class='brush:php;toolbar:false;'>composer require twig/twig</pre>
      <p><code>js</code>、<code>css</code>、<code>url</code>和<code>html_attr</code>轉(zhuǎn)義策略也可使用。它們分別為Javascript、CSS、URI和HTML屬性上下文轉(zhuǎn)義字符串。 </p>
      <p><strong>調(diào)試</strong></p>
      <p>最後,讓我們來看看調(diào)試。有時我們需要訪問模板變量的所有信息。為此,Twig具有<code>dump()</code>函數(shù)。此函數(shù)默認情況下不可用。在創(chuàng)建Twig環(huán)境時,我們必須添加<code>Twig_Extension_Debug</code>擴展:</p>
      <pre class='brush:php;toolbar:false;'><?php
      // 加載我們的自動加載器
      require_once __DIR__.'/vendor/autoload.php';
      
      // 指定我們的Twig模板位置
      $loader = new Twig_Loader_Filesystem(__DIR__.'/templates');
      
      // 實例化我們的Twig
      $twig = new Twig_Environment($loader);</pre>
      <p>此步驟是必要的,這樣我們才不會意外地在生產(chǎn)服務(wù)器上洩露調(diào)試信息。配置完成後,我們只需使用<code>dump()</code>函數(shù)即可轉(zhuǎn)儲有關(guān)模板變量的所有信息。 </p>
      <pre class='brush:php;toolbar:false;'><?php
      require_once __DIR__.'/bootstrap.php';
      
      // 創(chuàng)建產(chǎn)品列表
      $products = [
          [
              'name'          => 'Notebook',
              'description'   => 'Core i7',
              'value'         =>  800.00,
              'date_register' => '2017-06-22',
          ],
          [
              'name'          => 'Mouse',
              'description'   => 'Razer',
              'value'         =>  125.00,
              'date_register' => '2017-10-25',
          ],
          [
              'name'          => 'Keyboard',
              'description'   => 'Mechanical Keyboard',
              'value'         =>  250.00,
              'date_register' => '2017-06-23',
          ],
      ];
      
      // 渲染我們的視圖
      echo $twig->render('index.html', ['products' => $products] );</pre>
      <p><strong>結(jié)論</strong></p>
      <p>希望本文能為您提供Twig基礎(chǔ)知識的堅實基礎(chǔ),並立即啟動您的項目!如果您想更深入地了解Twig,官方網(wǎng)站提供了您可以查閱的非常好的文檔和參考。您使用模板引擎嗎?您對Twig有什麼看法?您會將它與Blade或Smarty等流行的替代方案進行比較嗎? </p>
      <p><strong>(以下內(nèi)容為FAQ,原文已包含,此處略去)</strong></p><p>以上是樹枝 - 最受歡迎的獨立PHP模板引擎的詳細內(nèi)容。更多資訊請關(guān)注PHP中文網(wǎng)其他相關(guān)文章!</p>
      
      
      						</div>
      					</div>
      					<div   id="377j5v51b"   class="wzconShengming_sp">
      						<div   id="377j5v51b"   class="bzsmdiv_sp">本網(wǎng)站聲明</div>
      						<div>本文內(nèi)容由網(wǎng)友自願投稿,版權(quán)歸原作者所有。本站不承擔相應(yīng)的法律責任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請聯(lián)絡(luò)admin@php.cn</div>
      					</div>
      				</div>
      
      				<ins class="adsbygoogle"
           style="display:block"
           data-ad-format="autorelaxed"
           data-ad-client="ca-pub-5902227090019525"
           data-ad-slot="2507867629"></ins>
      
      
      
      				<div   id="377j5v51b"   class="AI_ToolDetails_main4sR">
      
      
      				<ins class="adsbygoogle"
              style="display:block"
              data-ad-client="ca-pub-5902227090019525"
              data-ad-slot="3653428331"
              data-ad-format="auto"
              data-full-width-responsive="true"></ins>
          
      
      
      					<!-- <div   id="377j5v51b"   class="phpgenera_Details_mainR4">
      						<div   id="377j5v51b"   class="phpmain1_4R_readrank">
      							<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
      								<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      									onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      									src="/static/imghw/hotarticle2.png" alt="" />
      								<h2>熱門文章</h2>
      							</div>
      							<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottom">
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819578.html" title="如何修復(fù)KB5060533無法在Windows 10中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復(fù)KB5060533無法在Windows 10中安裝?</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>4 週前</span>
      										<span>By DDD</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819730.html" title="沙丘:覺醒 - 在哪裡獲得絕緣織物" class="phpgenera_Details_mainR4_bottom_title">沙丘:覺醒 - 在哪裡獲得絕緣織物</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>4 週前</span>
      										<span>By Jack chen</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819016.html" title="Gmail登錄:如何註冊,登錄或登錄Gmail -Minitool" class="phpgenera_Details_mainR4_bottom_title">Gmail登錄:如何註冊,登錄或登錄Gmail -Minitool</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>1 個月前</span>
      										<span>By Jack chen</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819994.html" title="如何修復(fù)KB5060999無法在Windows 11中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復(fù)KB5060999無法在Windows 11中安裝?</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>3 週前</span>
      										<span>By DDD</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819536.html" title="污染的公會指南:阿瓦隆的淪陷" class="phpgenera_Details_mainR4_bottom_title">污染的公會指南:阿瓦隆的淪陷</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>4 週前</span>
      										<span>By Jack chen</span>
      									</div>
      								</div>
      														</div>
      							<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
      								<a href="http://miracleart.cn/zh-tw/article.html">顯示更多</a>
      							</div>
      						</div>
      					</div> -->
      
      
      											<div   id="377j5v51b"   class="phpgenera_Details_mainR3">
      							<div   id="377j5v51b"   class="phpmain1_4R_readrank">
      								<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/hottools2.png" alt="" />
      									<h2>熱AI工具</h2>
      								</div>
      								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_bottom">
      																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title">
      													<h3>Undress AI Tool</h3>
      												</a>
      												<p>免費脫衣圖片</p>
      											</div>
      										</div>
      																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title">
      													<h3>Undresser.AI Undress</h3>
      												</a>
      												<p>人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片</p>
      											</div>
      										</div>
      																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title">
      													<h3>AI Clothes Remover</h3>
      												</a>
      												<p>用於從照片中去除衣服的線上人工智慧工具。</p>
      											</div>
      										</div>
      																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title">
      													<h3>Clothoff.io</h3>
      												</a>
      												<p>AI脫衣器</p>
      											</div>
      										</div>
      																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173414504068133.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Video Face Swap" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_title">
      													<h3>Video Face Swap</h3>
      												</a>
      												<p>使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!</p>
      											</div>
      										</div>
      																</div>
      								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
      									<a href="http://miracleart.cn/zh-tw/ai">顯示更多</a>
      								</div>
      							</div>
      						</div>
      					
      
      
      					<div   id="377j5v51b"   class="phpgenera_Details_mainR4">
      						<div   id="377j5v51b"   class="phpmain1_4R_readrank">
      							<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
      								<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      									onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      									src="/static/imghw/hotarticle2.png" alt="" />
      								<h2>熱門文章</h2>
      							</div>
      							<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottom">
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819578.html" title="如何修復(fù)KB5060533無法在Windows 10中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復(fù)KB5060533無法在Windows 10中安裝?</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>4 週前</span>
      										<span>By DDD</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819730.html" title="沙丘:覺醒 - 在哪裡獲得絕緣織物" class="phpgenera_Details_mainR4_bottom_title">沙丘:覺醒 - 在哪裡獲得絕緣織物</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>4 週前</span>
      										<span>By Jack chen</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819016.html" title="Gmail登錄:如何註冊,登錄或登錄Gmail -Minitool" class="phpgenera_Details_mainR4_bottom_title">Gmail登錄:如何註冊,登錄或登錄Gmail -Minitool</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>1 個月前</span>
      										<span>By Jack chen</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819994.html" title="如何修復(fù)KB5060999無法在Windows 11中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復(fù)KB5060999無法在Windows 11中安裝?</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>3 週前</span>
      										<span>By DDD</span>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/1796819536.html" title="污染的公會指南:阿瓦隆的淪陷" class="phpgenera_Details_mainR4_bottom_title">污染的公會指南:阿瓦隆的淪陷</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<span>4 週前</span>
      										<span>By Jack chen</span>
      									</div>
      								</div>
      														</div>
      							<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
      								<a href="http://miracleart.cn/zh-tw/article.html">顯示更多</a>
      							</div>
      						</div>
      					</div>
      
      
      											<div   id="377j5v51b"   class="phpgenera_Details_mainR3">
      							<div   id="377j5v51b"   class="phpmain1_4R_readrank">
      								<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/hottools2.png" alt="" />
      									<h2>熱工具</h2>
      								</div>
      								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_bottom">
      																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/toolset/development-tools/92" title="記事本++7.3.1" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="記事本++7.3.1" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/toolset/development-tools/92" title="記事本++7.3.1" class="phpmain_tab2_mids_title">
      													<h3>記事本++7.3.1</h3>
      												</a>
      												<p>好用且免費的程式碼編輯器</p>
      											</div>
      										</div>
      																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/toolset/development-tools/93" title="SublimeText3漢化版" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3漢化版" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/toolset/development-tools/93" title="SublimeText3漢化版" class="phpmain_tab2_mids_title">
      													<h3>SublimeText3漢化版</h3>
      												</a>
      												<p>中文版,非常好用</p>
      											</div>
      										</div>
      																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/toolset/development-tools/121" title="禪工作室 13.0.1" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="禪工作室 13.0.1" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/toolset/development-tools/121" title="禪工作室 13.0.1" class="phpmain_tab2_mids_title">
      													<h3>禪工作室 13.0.1</h3>
      												</a>
      												<p>強大的PHP整合開發(fā)環(huán)境</p>
      											</div>
      										</div>
      																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Dreamweaver CS6" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_title">
      													<h3>Dreamweaver CS6</h3>
      												</a>
      												<p>視覺化網(wǎng)頁開發(fā)工具</p>
      											</div>
      										</div>
      																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
      											<a href="http://miracleart.cn/zh-tw/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_top_img">
      												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac版" />
      											</a>
      											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
      												<a href="http://miracleart.cn/zh-tw/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_title">
      													<h3>SublimeText3 Mac版</h3>
      												</a>
      												<p>神級程式碼編輯軟體(SublimeText3)</p>
      											</div>
      										</div>
      																	</div>
      								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
      									<a href="http://miracleart.cn/zh-tw/ai">顯示更多</a>
      								</div>
      							</div>
      						</div>
      										
      
      					
      					<div   id="377j5v51b"   class="phpgenera_Details_mainR4">
      						<div   id="377j5v51b"   class="phpmain1_4R_readrank">
      							<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
      								<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      									onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      									src="/static/imghw/hotarticle2.png" alt="" />
      								<h2>熱門話題</h2>
      							</div>
      							<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottom">
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/gmailyxdlrkzn" title="gmail信箱登陸入口在哪裡" class="phpgenera_Details_mainR4_bottom_title">gmail信箱登陸入口在哪裡</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/eyess.png" alt="" />
      											<span>8517</span>
      										</div>
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/tiezi.png" alt="" />
      											<span>17</span>
      										</div>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/java-tutorial" title="Java教學(xué)" class="phpgenera_Details_mainR4_bottom_title">Java教學(xué)</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/eyess.png" alt="" />
      											<span>1744</span>
      										</div>
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/tiezi.png" alt="" />
      											<span>16</span>
      										</div>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/cakephp-tutor" title="CakePHP 教程" class="phpgenera_Details_mainR4_bottom_title">CakePHP 教程</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/eyess.png" alt="" />
      											<span>1596</span>
      										</div>
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/tiezi.png" alt="" />
      											<span>56</span>
      										</div>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/laravel-tutori" title="Laravel 教程" class="phpgenera_Details_mainR4_bottom_title">Laravel 教程</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/eyess.png" alt="" />
      											<span>1537</span>
      										</div>
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/tiezi.png" alt="" />
      											<span>28</span>
      										</div>
      									</div>
      								</div>
      															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
      									<a href="http://miracleart.cn/zh-tw/faq/php-tutorial" title="PHP教程" class="phpgenera_Details_mainR4_bottom_title">PHP教程</a>
      									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/eyess.png" alt="" />
      											<span>1396</span>
      										</div>
      										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
      											<img src="/static/imghw/tiezi.png" alt="" />
      											<span>31</span>
      										</div>
      									</div>
      								</div>
      														</div>
      							<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
      								<a href="http://miracleart.cn/zh-tw/faq/zt">顯示更多</a>
      							</div>
      						</div>
      					</div>
      				</div>
      			</div>
      							<div   id="377j5v51b"   class="Article_Details_main2">
      					<div   id="377j5v51b"   class="phpgenera_Details_mainL4">
      						<div   id="377j5v51b"   class="phpmain1_2_top">
      							<a href="javascript:void(0);" class="phpmain1_2_top_title">Related knowledge<img
      									src="/static/imghw/index2_title2.png" alt="" /></a>
      						</div>
      						<div   id="377j5v51b"   class="phpgenera_Details_mainL4_info">
      
      													<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796820395.html" title="對基於PHP的API進行版本控制的最佳實踐是什麼?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/174983207178259.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="對基於PHP的API進行版本控制的最佳實踐是什麼?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796820395.html" title="對基於PHP的API進行版本控制的最佳實踐是什麼?" class="phphistorical_Version2_mids_title">對基於PHP的API進行版本控制的最佳實踐是什麼?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 14, 2025 am	 12:27 AM</span>
      								<p class="Articlelist_txts_p">基於toversionaphp,useUrl deuseUrl specteringforclarityAndEsofRouting,單獨的codetoavoidConflicts,dremecateOldVersionswithClearCommunication,andConsiderCustomHeadeSerlySerallyWhennEnncelsy.startbyplacingtheversionIntheUrl(E.G.,epi/api/v</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796822204.html" title="如何在PHP中實施身份驗證和授權(quán)?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/175035261135357.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="如何在PHP中實施身份驗證和授權(quán)?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796822204.html" title="如何在PHP中實施身份驗證和授權(quán)?" class="phphistorical_Version2_mids_title">如何在PHP中實施身份驗證和授權(quán)?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 20, 2025 am	 01:03 AM</span>
      								<p class="Articlelist_txts_p">tosecurelyhandleauthenticationandationallizationInphp,lofterTheSesteps:1.AlwaysHashPasswordSwithPassword_hash()andverifyusingspasspassword_verify(),usepreparedStatatementStopreventsqlineptions,andStoreSeruserDatain usseruserDatain $ _sessiveferterlogin.2.implementrole-2.imaccessccsccccccccccccccccccccccccc.</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796820386.html" title="PHP中的程序和麵向?qū)ο蟮木幊坦犂g有什麼區(qū)別?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/174983193177803.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP中的程序和麵向?qū)ο蟮木幊坦犂g有什麼區(qū)別?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796820386.html" title="PHP中的程序和麵向?qū)ο蟮木幊坦犂g有什麼區(qū)別?" class="phphistorical_Version2_mids_title">PHP中的程序和麵向?qū)ο蟮木幊坦犂g有什麼區(qū)別?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 14, 2025 am	 12:25 AM</span>
      								<p class="Articlelist_txts_p">procemal and object-tiriendedprogromming(oop)inphpdiffersimplessintustructure,可重複使用性和datahandling.1.procedural-Progrogursmingusesfunctimesfunctionsormanized sequalized sequalized sequiential,poiperforsmallscripts.2.OpporganizesCodeOrganizescodeOdeIntsocloceSandObjects,ModelingReal-Worlden-Worlden</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796820387.html" title="PHP中有哪些弱參考(弱圖),何時有用?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/174983195046134.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP中有哪些弱參考(弱圖),何時有用?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796820387.html" title="PHP中有哪些弱參考(弱圖),何時有用?" class="phphistorical_Version2_mids_title">PHP中有哪些弱參考(弱圖),何時有用?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 14, 2025 am	 12:25 AM</span>
      								<p class="Articlelist_txts_p">PHPdoesnothaveabuilt-inWeakMapbutoffersWeakReferenceforsimilarfunctionality.1.WeakReferenceallowsholdingreferenceswithoutpreventinggarbagecollection.2.Itisusefulforcaching,eventlisteners,andmetadatawithoutaffectingobjectlifecycles.3.YoucansimulateaWe</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796821722.html" title="如何在PHP中安全地處理文件上傳?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/175026630154351.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="如何在PHP中安全地處理文件上傳?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796821722.html" title="如何在PHP中安全地處理文件上傳?" class="phphistorical_Version2_mids_title">如何在PHP中安全地處理文件上傳?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 19, 2025 am	 01:05 AM</span>
      								<p class="Articlelist_txts_p">要安全處理PHP中的文件上傳,核心在於驗證文件類型、重命名文件並限制權(quán)限。 1.使用finfo_file()檢查真實MIME類型,僅允許特定類型如image/jpeg;2.用uniqid()生成隨機文件名,存儲至非Web根目錄;3.通過php.ini和HTML表單限製文件大小,設(shè)置目錄權(quán)限為0755;4.使用ClamAV掃描惡意軟件,增強安全性。這些步驟有效防止安全漏洞,確保文件上傳過程安全可靠。</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796821728.html" title="如何與PHP的NOSQL數(shù)據(jù)庫(例如MongoDB,Redis)進行交互?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/175026645186884.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="如何與PHP的NOSQL數(shù)據(jù)庫(例如MongoDB,Redis)進行交互?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796821728.html" title="如何與PHP的NOSQL數(shù)據(jù)庫(例如MongoDB,Redis)進行交互?" class="phphistorical_Version2_mids_title">如何與PHP的NOSQL數(shù)據(jù)庫(例如MongoDB,Redis)進行交互?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 19, 2025 am	 01:07 AM</span>
      								<p class="Articlelist_txts_p">是的,PHP可以通過特定擴展或庫與MongoDB和Redis等NoSQL數(shù)據(jù)庫交互。首先,使用MongoDBPHP驅(qū)動(通過PECL或Composer安裝)創(chuàng)建客戶端實例並操作數(shù)據(jù)庫及集合,支持插入、查詢、聚合等操作;其次,使用Predis庫或phpredis擴展連接Redis,執(zhí)行鍵值設(shè)置與獲取,推薦phpredis用於高性能場景,Predis則便於快速部署;兩者均適用於生產(chǎn)環(huán)境且文檔完善。</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796821729.html" title="PHP中==(鬆散比較)和===(嚴格的比較)之間有什麼區(qū)別?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/175026647097920.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP中==(鬆散比較)和===(嚴格的比較)之間有什麼區(qū)別?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796821729.html" title="PHP中==(鬆散比較)和===(嚴格的比較)之間有什麼區(qū)別?" class="phphistorical_Version2_mids_title">PHP中==(鬆散比較)和===(嚴格的比較)之間有什麼區(qū)別?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 19, 2025 am	 01:07 AM</span>
      								<p class="Articlelist_txts_p">在PHP中,==與===的主要區(qū)別在於類型檢查的嚴格程度。 ==在比較前會進行類型轉(zhuǎn)換,例如5=="5"返回true,而===要求值和類型都相同才會返回true,例如5==="5"返回false。使用場景上,===更安全應(yīng)優(yōu)先使用,==僅在需要類型轉(zhuǎn)換時使用。</p>
      							</div>
      														<div   id="377j5v51b"   class="phphistorical_Version2_mids">
      								<a href="http://miracleart.cn/zh-tw/faq/1796821933.html" title="如何在PHP( - , *, /,%)中執(zhí)行算術(shù)操作?" class="phphistorical_Version2_mids_img">
      									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
      										src="/static/imghw/default1.png" class="lazy"  data-src="https://img.php.cn/upload/article/001/253/068/175032439158710.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="如何在PHP( - , *, /,%)中執(zhí)行算術(shù)操作?" />
      								</a>
      								<a href="http://miracleart.cn/zh-tw/faq/1796821933.html" title="如何在PHP( - , *, /,%)中執(zhí)行算術(shù)操作?" class="phphistorical_Version2_mids_title">如何在PHP( - , *, /,%)中執(zhí)行算術(shù)操作?</a>
      								<span id="377j5v51b"    class="Articlelist_txts_time">Jun 19, 2025 pm	 05:13 PM</span>
      								<p class="Articlelist_txts_p">PHP中使用基本數(shù)學(xué)運算的方法如下:1.加法用 號,支持整數(shù)和浮點數(shù),也可用於變量,字符串數(shù)字會自動轉(zhuǎn)換但不推薦依賴;2.減法用-號,變量同理,類型轉(zhuǎn)換同樣適用;3.乘法用*號,適用於數(shù)字及類似字符串;4.除法用/號,需避免除以零,並註意結(jié)果可能是浮點數(shù);5.取模用%號,可用於判斷奇偶數(shù),處理負數(shù)時餘數(shù)符號與被除數(shù)一致。正確使用這些運算符的關(guān)鍵在於確保數(shù)據(jù)類型清晰並處理好邊界情況。</p>
      							</div>
      													</div>
      
      													<a href="http://miracleart.cn/zh-tw/be/" class="phpgenera_Details_mainL4_botton">
      								<span>See all articles</span>
      								<img src="/static/imghw/down_right.png" alt="" />
      							</a>
      											</div>
      				</div>
      					</div>
      	</main>
      	<footer>
          <div   id="377j5v51b"   class="footer">
              <div   id="377j5v51b"   class="footertop">
                  <img src="/static/imghw/logo.png" alt="">
                  <p>公益線上PHP培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!</p>
              </div>
              <div   id="377j5v51b"   class="footermid">
                  <a href="http://miracleart.cn/zh-tw/about/us.html">關(guān)於我們</a>
                  <a href="http://miracleart.cn/zh-tw/about/disclaimer.html">免責聲明</a>
                  <a href="http://miracleart.cn/zh-tw/update/article_0_1.html">Sitemap</a>
              </div>
              <div   id="377j5v51b"   class="footerbottom">
                  <p>
                      ? php.cn All rights reserved
                  </p>
              </div>
          </div>
      </footer>
      
      <input type="hidden" id="verifycode" value="/captcha.html">
      
      
      
      
      		<link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' />
      	
      	
      	
      	
      	
      
      	
      	
      
      
      
      
      
      
      <footer>
      <div class="friendship-link">
      <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p>
      <a href="http://miracleart.cn/" title="国产av日韩一区二区三区精品">国产av日韩一区二区三区精品</a>
      
      <div class="friend-links">
      
      
      </div>
      </div>
      
      </footer>
      
      
      <script>
      (function(){
          var bp = document.createElement('script');
          var curProtocol = window.location.protocol.split(':')[0];
          if (curProtocol === 'https') {
              bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
          }
          else {
              bp.src = 'http://push.zhanzhang.baidu.com/push.js';
          }
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(bp, s);
      })();
      </script>
      </body><div id="ytqiy" class="pl_css_ganrao" style="display: none;"><output id="ytqiy"><center id="ytqiy"><sub id="ytqiy"></sub></center></output><wbr id="ytqiy"></wbr><dd id="ytqiy"><wbr id="ytqiy"><input id="ytqiy"></input></wbr></dd><big id="ytqiy"></big><var id="ytqiy"><optgroup id="ytqiy"></optgroup></var><td id="ytqiy"><rt id="ytqiy"></rt></td><center id="ytqiy"></center><optgroup id="ytqiy"><form id="ytqiy"><listing id="ytqiy"><rp id="ytqiy"></rp></listing></form></optgroup><nobr id="ytqiy"><noframes id="ytqiy"></noframes></nobr><acronym id="ytqiy"></acronym><thead id="ytqiy"><xmp id="ytqiy"></xmp></thead><ul id="ytqiy"><ins id="ytqiy"></ins></ul><del id="ytqiy"><u id="ytqiy"></u></del><samp id="ytqiy"></samp><tbody id="ytqiy"></tbody><delect id="ytqiy"><strong id="ytqiy"></strong></delect><optgroup id="ytqiy"></optgroup><tr id="ytqiy"><rp id="ytqiy"><dfn id="ytqiy"><tt id="ytqiy"></tt></dfn></rp></tr><xmp id="ytqiy"><tt id="ytqiy"></tt></xmp><small id="ytqiy"></small><i id="ytqiy"><sup id="ytqiy"><pre id="ytqiy"></pre></sup></i><bdo id="ytqiy"><input id="ytqiy"><abbr id="ytqiy"><tbody id="ytqiy"></tbody></abbr></input></bdo><dd id="ytqiy"></dd><legend id="ytqiy"></legend><ol id="ytqiy"></ol><blockquote id="ytqiy"><pre id="ytqiy"><form id="ytqiy"></form></pre></blockquote><ins id="ytqiy"></ins><del id="ytqiy"></del><del id="ytqiy"></del><ol id="ytqiy"></ol><meter id="ytqiy"><thead id="ytqiy"><xmp id="ytqiy"><pre id="ytqiy"></pre></xmp></thead></meter><cite id="ytqiy"><thead id="ytqiy"></thead></cite><i id="ytqiy"><sup id="ytqiy"><input id="ytqiy"><label id="ytqiy"></label></input></sup></i><form id="ytqiy"><s id="ytqiy"><i id="ytqiy"><sup id="ytqiy"></sup></i></s></form><dfn id="ytqiy"><kbd id="ytqiy"></kbd></dfn><dl id="ytqiy"><var id="ytqiy"><optgroup id="ytqiy"><bdo id="ytqiy"></bdo></optgroup></var></dl><video id="ytqiy"></video><abbr id="ytqiy"></abbr><i id="ytqiy"><bdo id="ytqiy"><listing id="ytqiy"><label id="ytqiy"></label></listing></bdo></i><ruby id="ytqiy"><listing id="ytqiy"><label id="ytqiy"><wbr id="ytqiy"></wbr></label></listing></ruby><ol id="ytqiy"></ol><dd id="ytqiy"><dfn id="ytqiy"><form id="ytqiy"><meter id="ytqiy"></meter></form></dfn></dd><menuitem id="ytqiy"></menuitem><dl id="ytqiy"></dl><div id="ytqiy"><th id="ytqiy"><u id="ytqiy"></u></th></div><th id="ytqiy"><optgroup id="ytqiy"><li id="ytqiy"><noframes id="ytqiy"></noframes></li></optgroup></th><sub id="ytqiy"></sub><meter id="ytqiy"><thead id="ytqiy"><th id="ytqiy"><ol id="ytqiy"></ol></th></thead></meter><wbr id="ytqiy"></wbr><var id="ytqiy"></var><source id="ytqiy"></source><u id="ytqiy"></u><li id="ytqiy"><strong id="ytqiy"><s id="ytqiy"></s></strong></li><small id="ytqiy"></small><abbr id="ytqiy"></abbr><center id="ytqiy"><sub id="ytqiy"><dd id="ytqiy"><dfn id="ytqiy"></dfn></dd></sub></center><acronym id="ytqiy"><dfn id="ytqiy"><form id="ytqiy"><td id="ytqiy"></td></form></dfn></acronym><i id="ytqiy"></i><xmp id="ytqiy"><listing id="ytqiy"><abbr id="ytqiy"></abbr></listing></xmp><pre id="ytqiy"><sub id="ytqiy"></sub></pre><small id="ytqiy"><nobr id="ytqiy"><strong id="ytqiy"></strong></nobr></small><i id="ytqiy"></i><abbr id="ytqiy"><option id="ytqiy"></option></abbr><optgroup id="ytqiy"></optgroup><tr id="ytqiy"><option id="ytqiy"><small id="ytqiy"></small></option></tr><th id="ytqiy"><td id="ytqiy"><delect id="ytqiy"><pre id="ytqiy"></pre></delect></td></th><style id="ytqiy"></style><noframes id="ytqiy"></noframes><xmp id="ytqiy"></xmp><samp id="ytqiy"><tt id="ytqiy"><delect id="ytqiy"></delect></tt></samp><cite id="ytqiy"><strong id="ytqiy"><fieldset id="ytqiy"></fieldset></strong></cite><fieldset id="ytqiy"><label id="ytqiy"></label></fieldset><dl id="ytqiy"></dl><option id="ytqiy"></option><optgroup id="ytqiy"></optgroup><nav id="ytqiy"></nav><option id="ytqiy"></option><strike id="ytqiy"></strike><em id="ytqiy"></em><ol id="ytqiy"></ol><mark id="ytqiy"><em id="ytqiy"><option id="ytqiy"><nav id="ytqiy"></nav></option></em></mark><small id="ytqiy"><nobr id="ytqiy"><noframes id="ytqiy"></noframes></nobr></small><button id="ytqiy"><b id="ytqiy"><del id="ytqiy"></del></b></button><em id="ytqiy"></em><th id="ytqiy"><em id="ytqiy"><center id="ytqiy"></center></em></th><kbd id="ytqiy"></kbd><ol id="ytqiy"></ol><abbr id="ytqiy"><dfn id="ytqiy"><th id="ytqiy"></th></dfn></abbr><dfn id="ytqiy"></dfn><tbody id="ytqiy"><th id="ytqiy"></th></tbody><th id="ytqiy"></th><acronym id="ytqiy"></acronym><small id="ytqiy"></small><thead id="ytqiy"><menuitem id="ytqiy"></menuitem></thead><xmp id="ytqiy"></xmp><cite id="ytqiy"><thead id="ytqiy"></thead></cite><nav id="ytqiy"></nav><label id="ytqiy"></label></div>
      
      </html>