Lets take an example. Suppose we have a page that has two voting polls on it. You break up your application to create a poll class and store its definition in poll.php.
poll.php
class poll {
function poll () {
}
function Show($pollId) {
// database stuff based on pollId
.
.
echo $pollHtml;
}
.
.
}
And lets create a logo file.
logo.php
<div id="logo">
<img src="logo.jpg" alt="our logo"/>
</div>
Now suppose these polls are to displayed on the home page. Since poll.php contains the DEFINITION of a poll class, there is no need to multi define it in our code. To prevent that, we use require_once("poll.php") instead.
index.php
<?php require_once("poll.php"); ?>
<html>
<head><title>Poll Page</title</head>
<body>
<div id="page">
<div id="header">
<?php require("logo.php");
<?php require_once("header.php");
</div>
<div id="president-poll">
<?php
$poll = new Poll();
$poll->Show(1);
?>
</div>
<div id="mayor-poll">
<?php
$poll = new Poll();
$poll->Show(2);
?>
</div>
<div id="footer">
<?php require_once("footer.php");
<?php require("logo.php");
</div>
</div>
</body>
</html>
In the above, suppose we wanted to show our logo on both the header and footer sections. Notice that we use require and not require_once because we want to use logo.php multiple times.
if you used require_once("logo.php") in both the header and footer, the second require_once won't show the logo in the footer.
I hope this gives you an idea of both.