PHP Function with Optional Parameters
original source : http://stackoverflow.com/questions/3978929/php-function-with-optional-parameters
To accomplish what you want, use an array Like Rabbot said (though this can become a pain to document/maintain if used excessively). Or just use the traditional optional args.
//My function with tons of optional params
function my_func($req_a, $req_b, $opt_a = NULL, $opt_b = NULL, $opt_c = NULL)
{
//Do stuff
}
my_func('Hi', 'World', null, null, 'Red');
However, I usually find that when I start writing a function/method
with that many arguments – more often than not it is a code smell, and
can be re-factored/abstracted into something much cleaner.
//Specialization of my_func - assuming my_func itself cannot be refactored
function my_color_func($reg_a, $reg_b, $opt = 'Red')
{
return my_func($reg_a, $reg_b, null, null, $opt);
}
my_color_func('Hi', 'World');
my_color_func('Hello', 'Universe', 'Green');
Managing Cron Jobs with PHP – Tuts+ Code Tutorial
The cronTab, or “Cron Table”, is a Linux system process / daemon which facilitates the scheduling of repetitive tasks thereby easing up our day to day routine.
In this tutorial, we’ll create a dynamic PHP class that, using a secure connection, provides us with a means to manipulate the cronTab! | Difficulty: Intermediate; Length: Quick; Tags: PHP, Web Development
origianl source :http://wiki.cerbweb.com/Installing_PHP_Mailparse
You will need to install the following packages
sudo apt-get install php5-gd php5-imap php-pear php5-dev make php5-mcrypt
Now you can install mailparse
sudo pecl install mailparse
Next edit your php.ini file and add mailparse.so
sudo nano /etc/php5/apache2/conf.d/mailparse.ini
or
sudo nano /etc/php5/conf.d/mailparse.ini
This will create a new file. Add the line
extension=mailparse.so