Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between introducing include and require into files in php

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what are the differences between include and require in php files. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Php files introduce (load) the difference between include and require

Description: file loading can be php file or html file

Loading methods: include and require include_once and require_once

There are two results loaded in:

1. The contents of the file are loaded and run

If loading content: include 'File path to load'

Include 'mysqldb.php'

two。 Get return data

If it is data include ('File path to get data')

/ / get data define ('ROOT',str_replace ('\\','/', _ _ DIR__).); $res = include (ROOT.'config.php')

Note:

The path must be written to the folder directory, and the complete path must be written (which can be obtained with _ DIR_)

The difference between Include and require:

The level of error is different, resulting in different results after running errors.

If an error occurs in include, it does not affect the running of the code on the current page of the program.

If there is an error in require, it will affect the running of the code of the program and will not be executed further.

The difference between not adding once and adding once:

The way to add once will only be introduced once no matter how many times a file is introduced.

The way not to add once is to run the code as many times as you import the file.

On "what are the differences between include and require in php files?" this article ends here. I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report