Okay, I’m going to give your questions a shot…hopefully this helps:
What you need on your server:
You need to have PHP installed on your server. If you have web hosting through any of the common providers, that’s probably already taken care of for you. You should be all set to start using PHP right away.
The trick is that in order for PHP to parse your files, they need to have the .php extension. Practically speaking, there’s nothing wrong with having a .php file that contains only HTML code, so my advice is to rename all of your .html files to the .php extension. That way, any PHP code found within them will be properly executed.
As to your question about linking a function, this is accomplished by way of the PHP include() or require() function. These functions accomplish basically the same thing with the exception that require() will cause a failure if it’s unable to find the file you wish to include.
Let’s say you have a file called index.php. Inside of that you have the following PHP code:
[php]
<?php
$result = my_special_function();
?>
[/php]
As you can see, I haven’t defined my_special_function() anywhere inside of index.php, so when I try to run this code, it’s going to break. I have two options for making index.php aware of my_special_function(). I can either include the function inside of index.php (which is basically what you’re doing), or, I can put it inside of a different file and simply include that file inside of index.php:
Let’s say I have another file, functions.php:
[php]
<?php
function my_special_function(){
return "This is what I do";
}
?>
[/php]
I define my_special_function() inside of that file, and I want to be able to use that definition in my index.php. I simply do this:
[php]
<?php
include('functions.php');
$result = my_special_function();
echo $result;
?>
[/php]
The above code will work. Just keep in mind that the argument to the include() or require() methods is the path to the php file that contains the functions/html/information you need.
You can check out more info on include() and require() here:
http://php.net/manual/en/function.include.php
http://www.php.net/manual/en/function.require.php