How to use functions in Skeleton
You can use functions however you please, but Skeleton is set up to handle them in a specific way if you choose to take advantage of it.
Normally to use a function you would include a file with all your functions and call it - like sample_function('parameter') for instance. The problem with this is that you're including functions even when you're not using them. I have functions.php files that get thousands of lines long, so at some point it becomes silly to include them all to only use a few.
In Skeleton, each function is put in its own file. The name of the function is the same as the name of the file (function.php). Functions are kept in the /system/functions folder. Take a look in /system/functions/sample_function.php if you like.
Skeleton calls functions using a function called fnc(). If want to call my sample_function() function I would call it like this:
fnc('sample_function')
To pass it arguments I would call it like this:
fnc('sample_function', 'argument 1', 'argument 2')
Why? Well, you're only including the functions you need and once a function is included PHP has it and doesn't have to include it again. The simple answer is: efficiency.
Example
function sample_function($param1, $param2)
{
$output = 'This is the output of sample_function().';
if(isset($param1))
{
$output .= ' You are using this function with a paramter.';
}
if(isset($param2))
{
.= '.. Multiple paramters even.';
}
}
The following is the output from
<?=fnc('sample_function', 'param', 'param')?>
This is the output of sample_function(). You are using this function with a paramter... Multiple paramters even.