Page 1 of 1
include and include_once()
Posted: Mon Feb 05, 2007 1:50 am
by siyaco
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
Posted: Mon Feb 05, 2007 2:19 am
by Christopher
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.
Posted: Mon Feb 05, 2007 2:23 am
by kaszu
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.
Posted: Mon Feb 05, 2007 2:31 am
by siyaco
thanks