We have given a string and the task is to count number of characters in a string str in PHP. In order to do this task, we have the following methods in PHP: Method 1: Using strlen() Method: The strlen() method is used to get the length of a given string str. L ength of the string including all the white spaces and special characters in this