The difference between require and include is that the script will terminate with an error if you use require and the file is not found.
Include example:
<?php
include 'non-existant-file';
echo "hello";
?>
Output:
hello
Require example:
<?php
require 'non-existant-file';
echo "hello";
?>
Output:
Fatal error: Failed opening required 'non-existant-file'
So you will want to use require whenever the content of the included file must be there to continue through your script.
include_once and require_once means that the file will only be included the first time you hit a _once statement.
Example:
include.php
<?php
echo "hello":
?>
script.php
<?php
include_once 'include.php';
if (TRUE) {
include_once 'include.php';
echo "Gutentag";
}
else {
echo "hi";
}
?>
When that script goes through the parser then include.php is only inserted the first time you hit the include_once. So the resulting code actually looks like:
<?php
echo "hello";
if (TRUE) {
echo "Gutentag";
}
else {
echo "hi";
}
?>