Sr. PHP Programmer Question: Download Senior PHP Programmer PDF

require_once(), require(), include(). What is difference between them?

Tweet Share WhatsApp

Answer:

require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

Download Senior PHP Programmer PDF Read All 202 Senior PHP Programmer Questions
Previous QuestionNext Question
What is the purpose of _FILE_ constant?Tell me how to set cookies in PHP?