This function comes in handy, and I believe is the only solution, when you have an optional parameter that can take any type of data.
For example:
<?php
function my_function($name, $data = null)
{
if ($data !== null)
{
}
}
?>
The problem with the above function is that you will never be able to use null as the value for $data. To fix this, use func_num_args() like so:
<?php
function my_function($name, $data = null)
{
if (func_num_args() >= 2)
{
}
}
?>
This solution works because func_num_args() reports exactly how many arguments were passed when the function was called. It does not take into account when default argument values are used.