Home > Backend Development > PHP Tutorial > PHP include usage

PHP include usage

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:04:09
Original
2353 people have browsed it

I’m used to the syntax of C++ and think that include only contains some header files. PHP’s include has more uses than that.

1. Contain some class definition files and function files, which are commonly used;

2. Contain HTML files

include "header.htm";

The above header.htm can be integrated with PHP statements.

Because htm static files can be included, a caching mechanism can be designed. For example, some pages can be divided into several parts. Some parts that are inefficient in reading the database can be cached as HTML and then introduced through include.

3.include files can have returns;

$i = include 'abc.php';

abc.php source code example:

return "hello world";

? >

Then echo $i; will output hello world.

And if abc.php has no return. Then echo $i will output the variable range of 1

include

$a="hello world";

include "abc.php";

$a is visible in abc.php; the variables in

abc.php are also visible after include; the usage is very flexible!

The above introduces the use of PHP include, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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