Yes, all of that is possible. For example, if I wanted to create a "library" of functions that will be used a bunch of times in different places, I would create a file called functions.php. In there I put this function:
function hiMom()
{
echo 'Hi Mom!';
}
It's just a demonstration function, but it gets the point across.
Now, if I have index.php and I want to use that function, I just [man]include[/man] our library into that index.php file like so:
<?php include('functions.php'); ?>
Now, you can include, [man]include_once[/man], [man]require[/man], and [man]require_once[/man] any number of files that you need. Also note that if you put functions.php inside of a folder and index.php is outside that folder, you need to specify the path to functions.php as well. For our example, I'm assuming they reside in the same folder.
Once I include that file, I can now use any of those functions that were defined. So in the html I might do something like this (note that this is the full index.php file):
<?php include('functions.php'); ?>
<html>
<head>
<title><?php hiMom(); ?></title>
</head>
<body>
<h1><?php hiMom(); ?></h1>
<p>This is just a test to see that my new function hiMom is really working:</p>
<p><?php hiMom(); ?></p>
</body>
</html>
Hope that helps.