I took a lazy Google look and didn’t see how to do this. If you want to use PHP to count characters in a string but only the visible text (in other words you don’t want to count the html— like links and whatnot), then just use this function. It returns the string length.
Of if you want to reject a string that is too long, try the below. It returns true if the string is within a limit, false if it exceeds the limit. Modify at as needed.
if($counter>$max) return true:return false;