0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【備忘録】require,require_once,includeの違い

0
Posted at

目的

require,require_once,includeの違いを知る

共通点

指定されたファイルを読み込み、評価します。

include

・ファイル探しに失敗した時は、warningを発行する

require

・ファイルをファイル探しに失敗した時は、fatal erorrを発行し、スクリプトを停止する

require_once

・ファイルをファイル探しに失敗した時は、fatal erorrを発行し、スクリプトを停止する。
・ファイルがすでに読み込まれているかどうかを PHP がチェックする。
・すでに読み込まれている場合はそのファイルを読み込まない。

まとめ

本番で、システム運用するときは、include使った方がいいのかな

参考資料

PHP公式ドキュメント
include
require
・[require_once]
(https://www.php.net/manual/ja/function.require-once.php#function.require-once)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?