How do I add my own PHP functions to Drupal

When you need to add your own php functions to drupal, you can simply embed them in the content, but that is not the best way.

The best way to add your own PHP functions to Drupal, would be to create your own function library module.

Lets hypothetically call your PHP function library "myfunctionlib", you will need to change that everywhere to reflect your own naming convention.

To create the PHP function library module first create a folder "myfunctionlib".

In that folder create a file called myfunctionlib.module with the following content:

<?php
/**
* Function Description
* @param function_parameter
* @returns function output description
*/

function myfunctionlibone($type="page") {
// php function code
}
function myfunctionlibtwo($show="list") {
// php function code
}
//don't close with ?>

In the same folder create another file called "myfunctionlib.info" with the following content:

name = My Function Library
description = This module contains my PHP helper functions.
core = 6.x
package = "MyFunctions"

version = "6.x-X.X"

"core" tells Drupal with which version of drupal the module works.
"version" tellds drupal what the version of this module is.

Upload the module folder "myfunctionlib" to the "sites/all/modules" folder, enable it on the modules administration page and call it where you want to use your php functions with;

<?php myfunctionlibtwo("block"); ?>
Don't forget to install and enable the PHP input filter if you have not done so already.

For more information on creating modules, coding standards, etc., see the Module developer's guide.