search
HomeBackend DevelopmentPHP ProblemDetailed explanation of php require usage

php require is a built-in function of PHP, which is used to introduce or include external PHP files. The working principle is that when the own PHP file is executed, the contents of the external file will be included in the own PHP file; When an error occurs in the included external file, the system will throw an error prompt and stop the execution of the php file.

Detailed explanation of php require usage

php require usage details

require() is a built-in function of php, which is used to introduce or include external php document.

Working principle: When the own PHP file is executed, the contents of the external file will be included in the own PHP file; when an error occurs in the included external file, the system will throw an error prompt, and Stop the execution of the php file.

Note: When using require, if there is an error in a file, the program will interrupt execution and display a fatal error.

For example, there are two files: cl.php and ts.php. If ts.php needs to use the functions in the cl.php file, it needs to be introduced or included in ts.php. The example is as follows:

cl.php

<?php
function  show(){
    echo "cl.php文件中的show方法被调用了!";
     
}
?>

ts.php

<?php
require &#39;cl.php&#39;;
show();
?>

Running result:

Detailed explanation of php require usage

For more related knowledge, please Visit PHP Chinese website!

The above is the detailed content of Detailed explanation of php require usage. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools