What potential errors can occur when using PHP functions to calculate logarithms and how can they be resolved?

When using PHP functions to calculate logarithms, potential errors can occur when trying to calculate the logarithm of zero or a negative number. To resolve this issue, you can add a check to ensure that the input to the logarithm function is a positive number greater than zero.

$num = 10;

if ($num > 0) {
    $logarithm = log($num);
    echo "The natural logarithm of $num is: $logarithm";
} else {
    echo "Error: Input must be a positive number greater than zero.";
}