what is the main difference between include and include_once() and what does it mean for security. because i heard that include_once is better for security, but i did not understand exactly
thanks all advance
include and include_once()
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
include_once is not for security. The difference is that include() will always include the file, but include_once() will not include the file if it has already been included. include_once() is to prevent variables, functions, and classes from being declared twice by including the same code again.
(#10850)
From php.net
include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.