I have a question on the way that functions are declared in PHP.
First test :
File "functions.php" => functions toto(){ return "1"; }
Main File
include("functions.php") functions toto(){ return "main"; } echo toto();
Second test
File "functions.php" => functions toto(){ return "1"; }
File "functions2.php" => functions toto(){ return "2"; }
Main File
include("functions.php") include("functions2.php") echo toto();
Results
The first test work and echo "main"
The second test doesn't work => fatal error "function toto already define"
I make complementary tests :
- in first test : put the functions toto() before include doesn't change the result.
- Create twice functions toto() in the main file create Fatal Error
Someone can explain me how exactly this work ?
Thanks for reading