PHP include_once Tutorial Print

  • 82

This PHP statement is very similar to include(), the only difference being that include_once() does exactly that.
The specified include will only be included in the running script once.

The standard include() statement could potentially include the same file many times during the execution of a script.
By using the include_once() statement, you ensure that the script is only ever included in the current execution path once.

This is the statement you should be using when including PHP library files containing functions and such, as it avoids the possibility of including the same library file twice, which would in turn result in duplicate function errors.


Was this answer helpful?

« Back