include, include_once, require or require_once?

前端 未结 8 1176
误落风尘
误落风尘 2020-11-27 17:21

I have PHP file where I have defined the server access variables as well as the mysql_connect and mysql_select_db, as this functions are regularly

8条回答
  •  [愿得一人]
    2020-11-27 17:46

    The only difference between the two is that require and its sister require_once throw a fatal error if the file is not found, whereas include and include_once only show a warning and continue to load the rest of the page. If you don't want PHP to attempt to load the rest of your page without the database info (which I would assume), then use require_once. You don't need to include the file more than once, so there is no need to use the regular require function.

提交回复
热议问题