How does php use the function defined by require in the process to succeed ;? Php $ testyes; fna ($ test); functionfna ($ a) {& nbsp; echo $ ;}? & Gt; however, a. php ---- & lt ;? Php $ testyes; fna ($ test); require (B. php );? & Gt; how does B php use the functions defined by require below the process?
This will succeed.
$ Test = 'yes ';
Fna ($ test );
Function fna ($)
{
Echo $;
}
?>
But in this way, you cannot call
A. php
----
$ Test = 'yes ';
Fna ($ test );
Require ('B. php ');
?>
B. php
----
Function fna ($)
{
Echo $;
}
?>
1. I know that you can directly call require by putting it in front.
2. google has another solution to use the autoload mechanism.
Is there no "declaration" solution?
------ Solution --------------------
Autoload is only applicable to automatic loading of class files, but not to functions.
What does "no" declaration "mean? You all know that require is always on the front. why do you need to take a detour?
------ Solution --------------------
Use function_exists to determine whether the specified file exists.
------ Solution --------------------
"Must be defined first and then used" is one of the main arguments for criticizing PHP.
Isn't it all about php grassroots? Non-standard? You can use undeclared variables!
So php developers listened to your opinion and gave up the priority of require during compilation.
Therefore, there is no qualitative difference between require and include.
Since you all insist on "first defining and then using", why does he need to maintain flexibility? After all, php is used as a tool for you.