What is the correct function to use in PHP to count the occurrences of specific characters within a string?

To count the occurrences of specific characters within a string in PHP, you can use the `substr_count()` function. This function takes two parameters - the string to search within and the character or substring to count. It returns the number of times the specified character or substring appears in the given string.

$string = "Hello, World!";
$char = "l";
$count = substr_count($string, $char);
echo "The character '$char' appears $count times in the string.";