php include include_once require require_once 的區別與聯絡

來源:互聯網
上載者:User

標籤:

一、require 與 include 的區別:

The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

這兩個方法基本沒有區別,除了在錯誤處理方面的。如果使用 include 方法出錯,這個方法拋出一個warning,不影響程式的繼續執行,但是 require 方法產生一個  fatal error,程式運行終止。

二、require 與 require_once 的區別:

The require_once() statement is identical to require() except PHP will check if the file has already been included,and if so, not include (require) it again.

這兩個方法的區別在於如果使用 require_once php 會檢查需要包含的檔案是否已經被包含了,如果是,那麼就不會重新包含。

php include include_once require require_once 的區別與聯絡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.