PHP String Functions

A string variable is used to store and manipulate text.

String Variables in PHP

String variables are used for values that contain characters.

<?php
$txt = "Learn Web Development things";
echo $txt;
?>

The output of the code above will be:
Learn Web Development things

Concatenation Operator
The concatenation operator (.) is used to put two string values together.

<?php
$txt1 = "Learn Web";
$txt2 = "Development things!";
echo $txt1 . " " . $txt2;
?>

The output of the code above will be:
Learn Web Development things!

strlen() function
The strlen() function is used to return the length of a string.

<?php
echo strlen("Learn Web Development");
?>

The output of the code above will be:
21

More PHP string Functions

Posted in Php