字符串:
并置运算符
并置运算” . “用于将两个字符串的值连接起来
Example:
$string1 = "Hello";
$string2 = "World";
// " "中括号是为了在Hello 和 world中生成一个空格
echo $string1 . " " .$string2;
OutPut:
Hello World
获取字符串长度strlen()
函数strlen()函数返回字符串的长度,字符个数
Example:
$string = "Hello World!!!!!!!!";
echo "字符串长度为:", strlen($string);
OutPut:
字符串长度为:19
字符串查找strpos()
函数strlen()函数返回字符串的长度,字符个数
Example:
$string = "nice to meet you";
echo strpos($string, "you");
echo strpos($string, "yM");
OutPut:
// 因为 string中并不包含yM,所以第二句什么都不会输出
13