PHP Basic
Introduction to PHP PHP Starting Requirements Downloading XAMPP Local Server PHP Variable Concept and Data Type PHP Coding Syntax Showing Output in PHP PHP String Concatenation Increment & Decrement in PHP PHP Logical Operator and Usage Part-1 PHP Logical Operator and Usage Part-2 PHP Comparison Operators Arithmetic and Assignment Operators PHP Switch Case Statement For loop in PHP Super Global Variable $_REQUEST and $_GET Part-1 String Length in PHP Function Declaration and UsageMost of the time it needs to find out the total size of a declared string. This helps during coding in form validation, in form input or something like that. Php has a built-in function to find out the total size of a string. The function is strlen() ; This function usually takes one parameter that is string and returns the size of that string. We can understand the process by below code
$bird = "Crow is a black bird"; $size = strlen($bird); echo "The size is " . $size;
Output
The size is 20
The output of this program is "The size is 20" that means string "Crow is a Blackbird" has 20 characters. It needs to remember in the programming world, space is also regarded as a character. We can see other examples also from below
$program = "PHP is a popular web programming language in today's world";
echo strlen($program);
The output of the PHP code for example 2 is
58
In this way, we can easily find out the size of a string.
If you think you have query... then For contacting with us use Facebook . You can also use Github