-
Step 1
To obtain the length of a string you use the strlen() function. It accepts one parameter and it must be of type string. The parameter is required so if you do not supply it you will receive an error.
-
Step 2
Lets say you have a variable called $mystring and you assign a string to that variable such as:
$mystring="Hello World!"
In the next step you will see how you insert the variable $mystring as the parameter required by the strlen() function. -
Step 3
To obtain the length of the string assigned to our variable $mystring we use it in this manner:
echo strlen($mystring);
this will print out the length as a number on the string. In our example the number 12 would be displayed on the screen.









