Home > Backend Development > PHP Tutorial > The difference between use and require in php

The difference between use and require in php

王林
Release: 2023-04-07 14:50:02
Original
4735 people have browsed it

The difference between use and require in php

The difference between use and require in PHP

1. require is an imported file, but if require cannot find the file, it will directly error and the program Exit;

2. Use uses a namespace, which is equivalent to the import package in java. The premise is that the files in the package need to be required or included in advance. When using use, you need to write the full space name and class name later.

For example: namespace Person1/Person; where Person1 is the namespace and Person is the class name.

Recommended tutorial: PHP video tutorial

The above is the detailed content of The difference between use and require in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template