• Register
Welcome to phpanswers , where you can ask questions and receive answers from other members of the community.

What are the differences between include() and include_once() functions?

0 votes
while working I found that include() and include_once() functions are including the files in the code and I wonder why php has introduced these two different functions for the same functionality so can anyone tell what is the exact difference between these two functions??
asked 2 years ago by Neeraj Narkhede (1,670 points)
edited 2 years ago by vikramapte

1 Answer

0 votes

 

include_once() statement includes the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.

answered 2 years ago by Neeraj Narkhede (1,670 points)
Since include_once() has to check if the file has been included already it is slower than include().

Related questions