TOC

PHP 字符串操作

  1. 单引号,双引号
  2. heredoc <<<EOF ... EOF;
  3. nowdoc <<<'EOF' ... EOF; 忽略变量和转义

操作

  1. 字符串连接 $s1 . $s2
  2. echo
  3. print
int printf ( string $format , mixed ...$args )
string sprintf ( string $format , mixed ...$args )
void var_dump ( mixed $expression , mixed ...$expressions )
mixed print_r ( mixed $expression [, bool $return = false ] )
strlen(string $string): int
substr(string $string, int $start, ?int $length = null): string|false
str_replace(string|array $search, string|array $replace, string|array $subject, ?int &$count = null): string|array|null
strpos(string $haystack, string $needle, ?int $offset = 0): int|false
explode(string $delimiter, string $string, ?int $limit = PHP_INT_MAX): array
implode(string $glue, array $pieces): string
strtolower(string $string): string
strtoupper(string $string): string
ucfirst(string $string): string
ucwords(string $string, string|null $delimiters = " \t\r\n\f\v"): string
trim(string $string, ?string $charlist = " \t\n\r\0\x0B"): string
str_repeat(string $string, int $multiplier): string
htmlspecialchars(string $string, int $flags = ENT_COMPAT | ENT_HTML401, ?string $encoding = ini_get("default_charset"), bool $double_encode = true): string
strtolower(string $string): string
strtoupper(string $string): string
lcfirst(string $string): string
strrev(string $string): string
ucfirst(string $string): string
ucwords(string $string): string
str_pad(string $string, int $length, string $pad_string = " ", int $pad_type = STR_PAD_RIGHT): string
strcmp(string $str1, string $str2): int
strcasecmp(string $str1, string $str2): int
stristr(string $haystack, string $needle, bool $before_needle = false): string|false
strstr(string $haystack, string $needle, bool $before_needle = false): string|false
strtok(string $string, string $delimiter): string|false
strpos(string $haystack, string $needle, ?int $offset = 0): int|false
strrpos(string $haystack, string $needle, ?int $offset = 0): int|false
substr_count(string $haystack, string $needle, ?int $offset = 0, ?int $length = null): int
substr_replace(string $string, string $replacement, int|array $start, ?int|array $length = null): string|array
wordwrap(string $string, ?int $width = 75, ?string $break = "\n", bool $cut = false): string
str_shuffle(string $string): string
str_split(string $string, int $split_length = 1): array
str_word_count(string $string, ?int $format = 0, ?string $charlist = ""): int|array
strcoll(string $str1, string $str2): int
strcspn(string $string, string $mask, ?int $start = 0, ?int $length = null): int
strip_tags(string $string, ?string $allowable_tags = null): string
html_entity_decode(string $string, ?int $flags = ENT_COMPAT | ENT_HTML401, ?string $encoding = ini_get("default_charset")): string
htmlentities(string $string, int $flags = ENT_COMPAT | ENT_HTML401, ?string $encoding = ini_get("default_charset"), bool $double_encode = true): string
htmlspecialchars_decode(string $string, ?int $flags = ENT_COMPAT | ENT_HTML401): string
preg_match(string $pattern, string $subject, ?array &$matches = null, ?int $flags = 0, int $offset = 0): int|false
preg_replace(mixed $pattern, mixed $replacement, mixed $subject, ?int $limit = -1, ?int &$count = null): mixed
preg_split(string $pattern, string $subject, ?int $limit = -1, ?int $flags = 0): array
substr_compare(string $main_str, string $str, int $offset, ?int $length = null, bool $case_insensitive = false): int
strcoll(string $str1, string $str2): int
strcspn(string $string, string $mask, ?int $start = 0, ?int $length = null): int
strip_tags(string $string, ?string $allowable_tags = null): string
strtr(string $string, string|array $replace_pairs): string
strval(mixed $var): string
substr_replace(string $string, string $replacement, int|array $start, ?int|array $length = null): string|array
levenshtein(string $str1, string $str2, ?int $cost_ins = 1, ?int $cost_rep = 1, ?int $cost_del = 1): int