PHP字符串

来源:互联网 发布:linux由sql server吗 编辑:程序博客网 时间:2024/06/05 16:35

字符串:

并置运算符

并置运算” . “用于将两个字符串的值连接起来

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
0 0
原创粉丝点击