|
String variables are used to store and manipulate a piece of text. $msg="Hello World"; echo $msg;
?> The output will be Hello World The Concatenation Operator Dot (.) is used as concatenation operator. To concatenate two variables together, use the dot (.) operator: $str1="Hello World"; $str2="Adam"; echo $ str1. " " . $ str2; ?>
Hello World Adam
Length of a String:
The strlen() function is used to find the length of a string. $string=”Hello World”;
echo strlen($string); ?> Output will be 11 The strpos() function: The strpos() function is used to search for a string or character within another string. If the string is found in the string, this function will return the position of the first match. If no match is found, it will return FALSE. echo strpos("Example of strops function","of"); ?>
The output will be 8 |