Home  >  Article  >  Backend Development  >  How to use require in PHP? ? Can't there be functions in external files? ?

How to use require in PHP? ? Can't there be functions in external files? ?

WBOY
WBOYOriginal
2016-08-18 09:16:351520browse

There is a function test in an external file demo1.php and an echo '000000';
require 'demo1.php' in another file demo2.php; echo '1111111';
Why do I call test in demo2 ( ), the following content within this field is not displayed? 1111111 is not displayed
not called, normal

Reply content:

There is a function test in an external file demo1.php and an echo '000000';
require 'demo1.php' in another file demo2.php; echo '1111111';
Why do I call test in demo2 ( ), the following content within this field is not displayed? 1111111 is not displayed
not called, normal

1 show me the code!

2 Turn on php error debugging. This should indicate that some error has occurred. You will know after typing out the error log.

How can the require 'demo1.php' be loaded if it is not in the same folder? The path must be written correctly

There may be errors in demo1, or demo1 may not exist.
It could also be your single quotes and semicolons.

It should be a Fatal error. You can turn on error reporting
error_reporting(E_ALL);
ini_set('display_errors', 'On')

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