I need to count the characters in a string. I thought count_chars() was the function to use but the number of characters in the string is not returned. This is what I'm doing:

if (count_chars($var) > 30) {$error = 'y';}

Is this the right function to use? What am I doing wrong?