We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Was this tool helpful to use?
Your feedback helps us make it better
Enter a PHP function name to quickly look up its description, parameters, and return values online.
A curated function and language-construct index. Recorded syntax and original snippets have not been verified for every PHP version or executed. Check the PHP manual for current parameters, extension requirements and version changes.
获取字符串的字节长度,注意中文 UTF-8 下一个汉字占 3 字节。
Recorded syntax (version unverified)
strlen(string $string): intOriginal snippet (not executed)
strlen('hello') // 5按多字节字符获取字符串长度,支持 UTF-8 等编码。
Recorded syntax (version unverified)
mb_strlen(string $string, ?string $encoding = null): intOriginal snippet (not executed)
mb_strlen('你好世界', 'UTF-8') // 4查找子串在字符串中第一次出现的位置,未找到返回 false。
Recorded syntax (version unverified)
strpos(string $haystack, string $needle, int $offset = 0): int|falseOriginal snippet (not executed)
strpos('hello world', 'world') // 6不区分大小写的 strpos 变体。
Recorded syntax (version unverified)
stripos(string $haystack, string $needle, int $offset = 0): int|falseOriginal snippet (not executed)
stripos('Hello', 'e') // 1在字符串中查找并替换内容,支持数组批量替换。
Recorded syntax (version unverified)
str_replace(array|string $search, array|string $replace, string|array $subject, int &$count = null): string|arrayOriginal snippet (not executed)
str_replace('foo', 'bar', 'foobar') // 'barbar'按正则模式查找并替换字符串。
Recorded syntax (version unverified)
preg_replace(string|array $pattern, string|array $replacement, string|array $subject): string|array|nullOriginal snippet (not executed)
preg_replace('/\\d+/', '#', 'abc123') // 'abc#'截取字符串的一部分,按字节计算。
Recorded syntax (version unverified)
substr(string $string, int $offset, ?int $length = null): stringOriginal snippet (not executed)
substr('hello', 1, 3) // 'ell'按多字节字符截取字符串。
Recorded syntax (version unverified)
mb_substr(string $string, int $start, ?int $length = null, ?string $encoding = null): stringOriginal snippet (not executed)
mb_substr('你好世界', 0, 2) // '你好'去除字符串首尾的空白字符或指定字符。
Recorded syntax (version unverified)
trim(string $string, string $characters = " \t\n\r\0\x0B"): stringOriginal snippet (not executed)
trim(' hi ') // 'hi'去除字符串左侧空白或指定字符。
Recorded syntax (version unverified)
ltrim(string $string, string $characters = " \t\n\r\0\x0B"): stringOriginal snippet (not executed)
ltrim(' hi') // 'hi'去除字符串右侧空白或指定字符。
Recorded syntax (version unverified)
rtrim(string $string, string $characters = " \t\n\r\0\x0B"): stringOriginal snippet (not executed)
rtrim('hi ') // 'hi'将字符串中的 ASCII 字母转换为小写。
Recorded syntax (version unverified)
strtolower(string $string): stringOriginal snippet (not executed)
strtolower('Hello') // 'hello'将字符串中的 ASCII 字母转换为大写。
Recorded syntax (version unverified)
strtoupper(string $string): stringOriginal snippet (not executed)
strtoupper('Hello') // 'HELLO'将字符串首字母转大写。
Recorded syntax (version unverified)
ucfirst(string $string): stringOriginal snippet (not executed)
ucfirst('hello world') // 'Hello world'将每个单词的首字母转大写。
Recorded syntax (version unverified)
ucwords(string $string, string $separators = " \t\r\n\f\v"): stringOriginal snippet (not executed)
ucwords('hello world') // 'Hello World'按指定分隔符将字符串拆分为数组。
Recorded syntax (version unverified)
explode(string $separator, string $string, int $limit = PHP_INT_MAX): arrayOriginal snippet (not executed)
explode(',', 'a,b,c') // ['a','b','c']用分隔符拼接数组为字符串,等同于 join。
Recorded syntax (version unverified)
implode(string $separator, array $array): stringOriginal snippet (not executed)
implode('-', ['a','b','c']) // 'a-b-c'按格式化字符串返回新的字符串,不直接输出。
Recorded syntax (version unverified)
sprintf(string $format, mixed ...$values): stringOriginal snippet (not executed)
sprintf('%05d', 42) // '00042'按千分位与指定小数位格式化数字。
Recorded syntax (version unverified)
number_format(float $num, int $decimals = 0, string $decimal_separator = '.', string $thousands_separator = ','): stringOriginal snippet (not executed)
number_format(1234567.891, 2) // '1,234,567.89'将字符串填充到指定长度。
Recorded syntax (version unverified)
str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT): stringOriginal snippet (not executed)
str_pad('5', 3, '0', STR_PAD_LEFT) // '005'将字符串重复指定次数后返回。
Recorded syntax (version unverified)
str_repeat(string $string, int $times): stringOriginal snippet (not executed)
str_repeat('ab', 3) // 'ababab'将字符串按固定长度分割为数组。
Recorded syntax (version unverified)
str_split(string $string, int $length = 1): arrayOriginal snippet (not executed)
str_split('hello', 2) // ['he','ll','o']把预定义的字符转换为 HTML 实体,防止 XSS。
Recorded syntax (version unverified)
htmlspecialchars(string $string, int $flags = ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML401, ?string $encoding = null, bool $double_encode = true): stringOriginal snippet (not executed)
htmlspecialchars('<a>') // '<a>'在字符串的每个换行符前插入 <br> 标签。
Recorded syntax (version unverified)
nl2br(string $string, bool $use_xhtml = true): stringOriginal snippet (not executed)
nl2br("a\nb") // 'a<br />\nb'统计数组元素的个数。
Recorded syntax (version unverified)
count(Countable|array $value, int $mode = COUNT_NORMAL): intOriginal snippet (not executed)
count([1,2,3]) // 3返回数组的所有键名,可指定值进行过滤。
Recorded syntax (version unverified)
array_keys(array $array, mixed $filter_value = null, bool $strict = false): arrayOriginal snippet (not executed)
array_keys(['a'=>1,'b'=>2]) // ['a','b']返回数组中所有值组成的索引数组。
Recorded syntax (version unverified)
array_values(array $array): arrayOriginal snippet (not executed)
array_values(['a'=>1,'b'=>2]) // [1,2]合并一个或多个数组,相同字符串键后者覆盖前者。
Recorded syntax (version unverified)
array_merge(array ...$arrays): arrayOriginal snippet (not executed)
array_merge(['a'=>1],['a'=>2,'b'=>3]) // ['a'=>2,'b'=>3]用一个数组的值作为键,另一个数组的值作为值组成新数组。
Recorded syntax (version unverified)
array_combine(array $keys, array $values): arrayOriginal snippet (not executed)
array_combine(['a','b'],[1,2]) // ['a'=>1,'b'=>2]对数组每个元素应用回调函数并返回新数组。
Recorded syntax (version unverified)
array_map(?callable $callback, array $array, array ...$arrays): arrayOriginal snippet (not executed)
array_map(fn($n)=>$n*2,[1,2,3]) // [2,4,6]用回调函数过滤数组元素,保留返回 true 的项。
Recorded syntax (version unverified)
array_filter(array $array, ?callable $callback = null, int $mode = 0): arrayOriginal snippet (not executed)
array_filter([0,1,2,'',3]) // [1=>1,2=>2,4=>3]用回调函数迭代地将数组归约为单一值。
Recorded syntax (version unverified)
array_reduce(array $array, callable $callback, mixed $initial = null): mixedOriginal snippet (not executed)
array_reduce([1,2,3], fn($c,$i)=>$c+$i, 0) // 6在数组中搜索给定值,返回第一个匹配的键,未找到返回 false。
Recorded syntax (version unverified)
array_search(mixed $needle, array $haystack, bool $strict = false): int|string|falseOriginal snippet (not executed)
array_search('b', ['a','b','c']) // 1检查值是否存在于数组中。
Recorded syntax (version unverified)
in_array(mixed $needle, array $haystack, bool $strict = false): boolOriginal snippet (not executed)
in_array(2, [1,2,3]) // true检查数组中是否存在指定的键名。
Recorded syntax (version unverified)
array_key_exists(string|int $key, array $array): boolOriginal snippet (not executed)
array_key_exists('a', ['a'=>null]) // true去除数组中重复的值。
Recorded syntax (version unverified)
array_unique(array $array, int $flags = SORT_STRING): arrayOriginal snippet (not executed)
array_unique([1,2,2,3]) // [0=>1,1=>2,3=>3]从数组中取出一段,类似 JavaScript 的 slice。
Recorded syntax (version unverified)
array_slice(array $array, int $offset, ?int $length = null, bool $preserve_keys = false): arrayOriginal snippet (not executed)
array_slice([1,2,3,4,5], 1, 2) // [2,3]移除数组的一部分并用其他元素替换。
Recorded syntax (version unverified)
array_splice(array &$array, int $offset, ?int $length = null, mixed $replacement = []): arrayOriginal snippet (not executed)
$a=[1,2,3]; array_splice($a, 1, 1, ['x','y']); // $a=[1,'x','y',3]返回元素顺序相反的数组。
Recorded syntax (version unverified)
array_reverse(array $array, bool $preserve_keys = false): arrayOriginal snippet (not executed)
array_reverse([1,2,3]) // [3,2,1]交换数组中的键与值。
Recorded syntax (version unverified)
array_flip(array $array): arrayOriginal snippet (not executed)
array_flip(['a'=>1,'b'=>2]) // [1=>'a',2=>'b']计算数组之间的差集(值比较)。
Recorded syntax (version unverified)
array_diff(array $array, array ...$arrays): arrayOriginal snippet (not executed)
array_diff([1,2,3],[2,4]) // [0=>1,2=>3]计算数组之间的交集(值比较)。
Recorded syntax (version unverified)
array_intersect(array $array, array ...$arrays): arrayOriginal snippet (not executed)
array_intersect([1,2,3],[2,3,4]) // [1=>2,2=>3]向数组末尾插入一个或多个元素。
Recorded syntax (version unverified)
array_push(array &$array, mixed ...$values): intOriginal snippet (not executed)
$a=[1]; array_push($a, 2, 3); // $a=[1,2,3]弹出数组末尾的元素。
Recorded syntax (version unverified)
array_pop(array &$array): mixedOriginal snippet (not executed)
$a=[1,2,3]; array_pop($a); // 返回 3, $a=[1,2]移除数组开头的元素并返回。
Recorded syntax (version unverified)
array_shift(array &$array): mixedOriginal snippet (not executed)
$a=[1,2,3]; array_shift($a); // 返回 1, $a=[2,3]在数组开头插入一个或多个元素。
Recorded syntax (version unverified)
array_unshift(array &$array, mixed ...$values): intOriginal snippet (not executed)
$a=[2,3]; array_unshift($a, 1); // $a=[1,2,3]对数组按值升序排序,重置键。
Recorded syntax (version unverified)
sort(array &$array, int $flags = SORT_REGULAR): boolOriginal snippet (not executed)
$a=[3,1,2]; sort($a); // $a=[1,2,3]对数组按值降序排序,重置键。
Recorded syntax (version unverified)
rsort(array &$array, int $flags = SORT_REGULAR): boolOriginal snippet (not executed)
$a=[1,3,2]; rsort($a); // $a=[3,2,1]使用用户自定义比较函数对数组进行排序。
Recorded syntax (version unverified)
usort(array &$array, callable $callback): boolOriginal snippet (not executed)
usort($a, fn($x,$y)=>$x<=>$y);按键名升序对数组进行排序。
Recorded syntax (version unverified)
ksort(array &$array, int $flags = SORT_REGULAR): boolOriginal snippet (not executed)
ksort($arr);从二维数组中获取一列的值。
Recorded syntax (version unverified)
array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): arrayOriginal snippet (not executed)
array_column($rows, 'name', 'id')返回数字的绝对值。
Recorded syntax (version unverified)
abs(int|float $num): int|floatOriginal snippet (not executed)
abs(-5) // 5对浮点数进行四舍五入。
Recorded syntax (version unverified)
round(int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): floatOriginal snippet (not executed)
round(1.555, 2) // 1.56对浮点数向上取整。
Recorded syntax (version unverified)
ceil(int|float $num): floatOriginal snippet (not executed)
ceil(1.2) // 2对浮点数向下取整。
Recorded syntax (version unverified)
floor(int|float $num): floatOriginal snippet (not executed)
floor(1.8) // 1返回参数中的最大值,支持数组与多个值。
Recorded syntax (version unverified)
max(mixed $value, mixed ...$values): mixedOriginal snippet (not executed)
max(1, 3, 2) // 3返回参数中的最小值。
Recorded syntax (version unverified)
min(mixed $value, mixed ...$values): mixedOriginal snippet (not executed)
min([4,2,5]) // 2返回 base 的 exp 次方。
Recorded syntax (version unverified)
pow(mixed $num, mixed $exponent): int|floatOriginal snippet (not executed)
pow(2, 10) // 1024返回数字的平方根。
Recorded syntax (version unverified)
sqrt(float $num): floatOriginal snippet (not executed)
sqrt(16) // 4生成一个伪随机整数。
Recorded syntax (version unverified)
rand(int $min, int $max): intOriginal snippet (not executed)
rand(1, 100)更快、质量更好的伪随机整数生成器。
Recorded syntax (version unverified)
mt_rand(int $min, int $max): intOriginal snippet (not executed)
mt_rand(0, 9999)生成密码学安全的伪随机整数。
Recorded syntax (version unverified)
random_int(int $min, int $max): intOriginal snippet (not executed)
random_int(100000, 999999) // 用于验证码通过字符串或浮点获取整数值。
Recorded syntax (version unverified)
intval(mixed $value, int $base = 10): intOriginal snippet (not executed)
intval('42abc') // 42通过字符串获取浮点数值。
Recorded syntax (version unverified)
floatval(mixed $value): floatOriginal snippet (not executed)
floatval('3.14abc') // 3.14返回当前 Unix 时间戳(秒)。
Recorded syntax (version unverified)
time(): intOriginal snippet (not executed)
time() // 1700000000返回当前 Unix 时间戳的毫秒部分与秒。
Recorded syntax (version unverified)
microtime(bool $as_float = false): string|floatOriginal snippet (not executed)
microtime(true) // 1700000000.1234按格式化字符串返回本地日期与时间。
Recorded syntax (version unverified)
date(string $format, ?int $timestamp = null): stringOriginal snippet (not executed)
date('Y-m-d H:i:s') // '2024-01-01 12:00:00'由具体日期时间分量生成 Unix 时间戳。
Recorded syntax (version unverified)
mktime(int $hour = ..., int $minute = ..., int $second = ..., int $month = ..., int $day = ..., int $year = ...): int|falseOriginal snippet (not executed)
mktime(0, 0, 0, 1, 1, 2024)将任意英文日期描述解析为时间戳。
Recorded syntax (version unverified)
strtotime(string $datetime, ?int $baseTimestamp = null): int|falseOriginal snippet (not executed)
strtotime('next monday')对 DateTime 对象按格式化字符串生成字符串。
Recorded syntax (version unverified)
date_format(DateTimeInterface $object, string $format): stringOriginal snippet (not executed)
date_format(new DateTime, 'Y-m-d')返回两个 DateTime 之间的差值 DateInterval。
Recorded syntax (version unverified)
date_diff(DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute = false): DateIntervalOriginal snippet (not executed)
date_diff($a, $b)->days校验给定的年月日是否为有效公历日期。
Recorded syntax (version unverified)
checkdate(int $month, int $day, int $year): boolOriginal snippet (not executed)
checkdate(2, 29, 2024) // true将整个文件读入字符串,也可读取 URL。
Recorded syntax (version unverified)
file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, ?int $length = null): string|falseOriginal snippet (not executed)
file_get_contents('config.json')将字符串写入文件,文件不存在时自动创建。
Recorded syntax (version unverified)
file_put_contents(string $filename, mixed $data, int $flags = 0, $context = null): int|falseOriginal snippet (not executed)
file_put_contents('log.txt', $msg, FILE_APPEND)打开文件或 URL 资源,返回文件指针。
Recorded syntax (version unverified)
fopen(string $filename, string $mode, bool $use_include_path = false, $context = null): resource|falseOriginal snippet (not executed)
$fp = fopen('data.csv', 'r')关闭一个已打开的文件指针。
Recorded syntax (version unverified)
fclose(resource $stream): boolOriginal snippet (not executed)
fclose($fp)向打开的文件写入数据。
Recorded syntax (version unverified)
fwrite(resource $stream, string $data, ?int $length = null): int|falseOriginal snippet (not executed)
fwrite($fp, 'hello')从文件指针读取指定长度的内容。
Recorded syntax (version unverified)
fread(resource $stream, int $length): string|falseOriginal snippet (not executed)
fread($fp, 1024)从文件指针读取一行。
Recorded syntax (version unverified)
fgets(resource $stream, ?int $length = null): string|falseOriginal snippet (not executed)
while ($line = fgets($fp)) { ... }判断文件或目录是否存在。
Recorded syntax (version unverified)
file_exists(string $filename): boolOriginal snippet (not executed)
file_exists('uploads/avatar.png')判断路径是否为常规文件。
Recorded syntax (version unverified)
is_file(string $filename): boolOriginal snippet (not executed)
is_file('a.txt')判断路径是否为目录。
Recorded syntax (version unverified)
is_dir(string $filename): boolOriginal snippet (not executed)
is_dir('/var/log')创建目录,可递归创建多级路径。
Recorded syntax (version unverified)
mkdir(string $directory, int $permissions = 0777, bool $recursive = false, $context = null): boolOriginal snippet (not executed)
mkdir('a/b/c', 0755, true)删除文件。
Recorded syntax (version unverified)
unlink(string $filename, $context = null): boolOriginal snippet (not executed)
unlink('temp.log')重命名或移动文件、目录。
Recorded syntax (version unverified)
rename(string $from, string $to, $context = null): boolOriginal snippet (not executed)
rename('old.txt', 'new.txt')拷贝文件到目标位置。
Recorded syntax (version unverified)
copy(string $from, string $to, $context = null): boolOriginal snippet (not executed)
copy('a.png', 'backup/a.png')返回文件大小(字节)。
Recorded syntax (version unverified)
filesize(string $filename): int|falseOriginal snippet (not executed)
filesize('image.jpg')列出目录中的文件和子目录。
Recorded syntax (version unverified)
scandir(string $directory, int $sorting_order = SCANDIR_SORT_ASCENDING, $context = null): array|falseOriginal snippet (not executed)
scandir('./public')按通配符匹配寻找文件路径。
Recorded syntax (version unverified)
glob(string $pattern, int $flags = 0): array|falseOriginal snippet (not executed)
glob('logs/*.log')返回路径的目录、文件名、扩展名等信息。
Recorded syntax (version unverified)
pathinfo(string $path, int $flags = PATHINFO_ALL): array|stringOriginal snippet (not executed)
pathinfo('/a/b.txt') // ['dirname'=>'/a',...]执行一次正则匹配,匹配成功返回 1。
Recorded syntax (version unverified)
preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int|falseOriginal snippet (not executed)
preg_match('/^\\d+$/', '123') // 1执行全局正则匹配,匹配多个结果。
Recorded syntax (version unverified)
preg_match_all(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int|falseOriginal snippet (not executed)
preg_match_all('/\\d+/', 'a1b2c3', $m); // $m[0]=['1','2','3']按正则表达式分割字符串。
Recorded syntax (version unverified)
preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array|falseOriginal snippet (not executed)
preg_split('/\\s+/', 'a b c') // ['a','b','c']对字符串中的正则特殊字符进行转义。
Recorded syntax (version unverified)
preg_quote(string $str, ?string $delimiter = null): stringOriginal snippet (not executed)
preg_quote('1+1=2') // '1\\+1=2'检测变量是否声明且不为 null。
Recorded syntax (version unverified)
isset(mixed $var, mixed ...$vars): boolOriginal snippet (not executed)
isset($_GET['id'])检测变量是否为空(0/''/null/false/空数组)。
Recorded syntax (version unverified)
empty(mixed $var): boolOriginal snippet (not executed)
empty($name)销毁变量。
Recorded syntax (version unverified)
unset(mixed $var, mixed ...$vars): voidOriginal snippet (not executed)
unset($tmp)获取变量类型字符串。
Recorded syntax (version unverified)
gettype(mixed $value): stringOriginal snippet (not executed)
gettype([1,2]) // 'array'判断变量是否为数组。
Recorded syntax (version unverified)
is_array(mixed $value): boolOriginal snippet (not executed)
is_array($x)判断变量是否为字符串。
Recorded syntax (version unverified)
is_string(mixed $value): boolOriginal snippet (not executed)
is_string($x)判断变量是否为数字或数字字符串。
Recorded syntax (version unverified)
is_numeric(mixed $value): boolOriginal snippet (not executed)
is_numeric('3.14') // true判断变量是否为 null。
Recorded syntax (version unverified)
is_null(mixed $value): boolOriginal snippet (not executed)
is_null($x)打印变量的详细信息,包括类型与值,常用于调试。
Recorded syntax (version unverified)
var_dump(mixed ...$values): voidOriginal snippet (not executed)
var_dump($obj)以易读形式打印变量信息,可返回字符串。
Recorded syntax (version unverified)
print_r(mixed $value, bool $return = false): string|trueOriginal snippet (not executed)
print_r($arr, true)将 PHP 变量编码为 JSON 字符串。
Recorded syntax (version unverified)
json_encode(mixed $value, int $flags = 0, int $depth = 512): string|falseOriginal snippet (not executed)
json_encode(['a'=>1], JSON_UNESCAPED_UNICODE)将 JSON 字符串解码为 PHP 变量。
Recorded syntax (version unverified)
json_decode(string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixedOriginal snippet (not executed)
json_decode('{"a":1}', true) // ['a'=>1]返回最近一次 JSON 操作的错误码。
Recorded syntax (version unverified)
json_last_error(): intOriginal snippet (not executed)
if (json_last_error() !== JSON_ERROR_NONE) { ... }对字符串按 application/x-www-form-urlencoded 进行编码。
Recorded syntax (version unverified)
urlencode(string $string): stringOriginal snippet (not executed)
urlencode('hello world') // 'hello+world'对 urlencoded 字符串进行解码。
Recorded syntax (version unverified)
urldecode(string $string): stringOriginal snippet (not executed)
urldecode('a%20b') // 'a b'按 RFC 3986 对字符串进行 URL 编码(空格变 %20)。
Recorded syntax (version unverified)
rawurlencode(string $string): stringOriginal snippet (not executed)
rawurlencode('a b') // 'a%20b'解析 URL,返回各个组成部分。
Recorded syntax (version unverified)
parse_url(string $url, int $component = -1): array|string|int|null|falseOriginal snippet (not executed)
parse_url('https://a.com/b?c=1') // ['scheme'=>'https',...]由数组生成 URL 编码后的查询字符串。
Recorded syntax (version unverified)
http_build_query(array|object $data, string $numeric_prefix = '', ?string $arg_separator = null, int $encoding_type = PHP_QUERY_RFC1738): stringOriginal snippet (not executed)
http_build_query(['a'=>1,'b'=>2]) // 'a=1&b=2'对字符串进行 Base64 编码。
Recorded syntax (version unverified)
base64_encode(string $string): stringOriginal snippet (not executed)
base64_encode('hello') // 'aGVsbG8='对 Base64 字符串进行解码。
Recorded syntax (version unverified)
base64_decode(string $string, bool $strict = false): string|falseOriginal snippet (not executed)
base64_decode('aGVsbG8=') // 'hello'计算字符串的 MD5 散列值(32 位十六进制)。
Recorded syntax (version unverified)
md5(string $string, bool $binary = false): stringOriginal snippet (not executed)
md5('hello') // '5d41402abc4b2a76b9719d911017c592'计算字符串的 SHA1 散列值。
Recorded syntax (version unverified)
sha1(string $string, bool $binary = false): stringOriginal snippet (not executed)
sha1('hello')通用散列函数,支持多种算法。
Recorded syntax (version unverified)
hash(string $algo, string $data, bool $binary = false): stringOriginal snippet (not executed)
hash('sha256', $data)使用 HMAC 算法生成带密钥的散列。
Recorded syntax (version unverified)
hash_hmac(string $algo, string $data, string $key, bool $binary = false): stringOriginal snippet (not executed)
hash_hmac('sha256', $data, $secret)用安全的算法(bcrypt/argon2)生成密码哈希。
Recorded syntax (version unverified)
password_hash(string $password, string|int|null $algo, array $options = []): stringOriginal snippet (not executed)
password_hash($pw, PASSWORD_DEFAULT)校验密码是否匹配 password_hash 生成的哈希。
Recorded syntax (version unverified)
password_verify(string $password, string $hash): boolOriginal snippet (not executed)
password_verify($input, $stored)计算字符串的 CRC32 校验和。
Recorded syntax (version unverified)
crc32(string $string): intOriginal snippet (not executed)
crc32('hello')初始化一个 cURL 会话。
Recorded syntax (version unverified)
curl_init(?string $url = null): CurlHandle|falseOriginal snippet (not executed)
$ch = curl_init('https://api.example.com')设置 cURL 会话选项。
Recorded syntax (version unverified)
curl_setopt(CurlHandle $handle, int $option, mixed $value): boolOriginal snippet (not executed)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true)执行 cURL 会话并返回结果。
Recorded syntax (version unverified)
curl_exec(CurlHandle $handle): string|boolOriginal snippet (not executed)
$body = curl_exec($ch)关闭 cURL 会话并释放资源。
Recorded syntax (version unverified)
curl_close(CurlHandle $handle): voidOriginal snippet (not executed)
curl_close($ch)发送原始 HTTP 头到客户端,须在任何输出之前调用。
Recorded syntax (version unverified)
header(string $header, bool $replace = true, int $response_code = 0): voidOriginal snippet (not executed)
header('Content-Type: application/json')向客户端发送 Cookie。
Recorded syntax (version unverified)
setcookie(string $name, string $value = '', int $expires_or_options = 0, string $path = '', string $domain = '', bool $secure = false, bool $httponly = false): boolOriginal snippet (not executed)
setcookie('uid', $uid, time()+3600, '/', '', true, true)启动新会话或恢复现有会话。
Recorded syntax (version unverified)
session_start(array $options = []): boolOriginal snippet (not executed)
session_start()销毁当前会话的全部数据。
Recorded syntax (version unverified)
session_destroy(): boolOriginal snippet (not executed)
session_destroy()获取或设置当前会话 ID。
Recorded syntax (version unverified)
session_id(?string $id = null): string|falseOriginal snippet (not executed)
session_id()更新当前会话 ID 并可选删除旧会话。
Recorded syntax (version unverified)
session_regenerate_id(bool $delete_old_session = false): boolOriginal snippet (not executed)
session_regenerate_id(true)检查类是否已定义。
Recorded syntax (version unverified)
class_exists(string $class, bool $autoload = true): boolOriginal snippet (not executed)
class_exists('App\\User')返回对象所属的类名。
Recorded syntax (version unverified)
get_class(?object $object = null): stringOriginal snippet (not executed)
get_class($user) // 'App\\User'检查类或对象是否存在指定方法。
Recorded syntax (version unverified)
method_exists(object|string $object_or_class, string $method): boolOriginal snippet (not executed)
method_exists($obj, 'save')检查对象或类是否存在指定属性。
Recorded syntax (version unverified)
property_exists(object|string $object_or_class, string $property): boolOriginal snippet (not executed)
property_exists($user, 'email')判断对象是否是给定类的实例或子类。
Recorded syntax (version unverified)
is_a(mixed $object_or_class, string $class, bool $allow_string = false): boolOriginal snippet (not executed)
is_a($user, User::class)运算符,判断对象是否属于某个类或实现某接口。
Recorded syntax (version unverified)
$obj instanceof ClassNameOriginal snippet (not executed)
if ($e instanceof \Exception) { ... }调用一个回调,包括函数名、闭包或方法数组。
Recorded syntax (version unverified)
call_user_func(callable $callback, mixed ...$args): mixedOriginal snippet (not executed)
call_user_func([$obj,'method'], $arg)输出消息并终止脚本,与 exit 等价。
Recorded syntax (version unverified)
die(string|int $status = ''): voidOriginal snippet (not executed)
die('error')终止脚本执行,可输出消息或返回退出码。
Recorded syntax (version unverified)
exit(string|int $status = ''): voidOriginal snippet (not executed)
exit(0)设置 PHP 的错误报告级别。
Recorded syntax (version unverified)
error_reporting(?int $error_level = null): intOriginal snippet (not executed)
error_reporting(E_ALL)获取 php.ini 配置项的值。
Recorded syntax (version unverified)
ini_get(string $option): string|falseOriginal snippet (not executed)
ini_get('upload_max_filesize')在运行时修改 php.ini 配置项。
Recorded syntax (version unverified)
ini_set(string $option, string|int|float|bool|null $value): string|falseOriginal snippet (not executed)
ini_set('memory_limit', '256M')返回当前运行的 PHP 版本。
Recorded syntax (version unverified)
phpversion(?string $extension = null): string|falseOriginal snippet (not executed)
phpversion() // '8.2.0'判断函数是否已定义。
Recorded syntax (version unverified)
function_exists(string $function): boolOriginal snippet (not executed)
if (function_exists('mb_strlen')) { ... }判断常量是否已被定义。
Recorded syntax (version unverified)
defined(string $constant_name): boolOriginal snippet (not executed)
defined('APP_ENV')定义一个常量。
Recorded syntax (version unverified)
define(string $constant_name, mixed $value, bool $case_insensitive = false): boolOriginal snippet (not executed)
define('APP_ENV', 'production')让脚本暂停指定秒数。
Recorded syntax (version unverified)
sleep(int $seconds): intOriginal snippet (not executed)
sleep(2)让脚本暂停指定微秒数。
Recorded syntax (version unverified)
usleep(int $microseconds): voidOriginal snippet (not executed)
usleep(500000) // 暂停 0.5 秒Overview
Understand what the tool solves, how it works, and the boundaries of its data.
This page helps you find a recorded PHP function or language construct by its name, category, or a keyword appearing in its description, syntax, example, or note. Matching ignores letter case. Choose a category such as String, Array, Date & Time, JSON, or File System to narrow the list, or leave the category on All. Each matching card shows its category, a short description, a syntax line, and a code example; you can copy the displayed name or signature.
Think of the result as a curated index for quick orientation. It is not the complete PHP manual, a version selector, or a PHP runtime: searching does not execute code or test whether an example works in your environment. The official PHP function and method listing and Function Reference cover a much broader documentation set.
A signature summarizes a callable’s name, parameter order, type hints, optional values, and sometimes its return type. A parameter with a default value is generally optional in that declaration; a return type such as int|false signals more than one possible result. Treat these lines as a starting point, then check the current manual entry for exact version and extension requirements.
Some familiar PHP constructs, including isset and empty, are language constructs rather than ordinary functions. A reference list can group them with functions because they are searched in a similar way, but their call syntax and rules are defined by the language.
The search controls are in English, but many embedded descriptions and notes are written in Chinese. Function names, signatures, and code examples use PHP syntax and may still help you locate an entry; the English interface does not translate those record summaries. If you need an English explanation, follow the linked PHP manual entry or search the official manual directly.
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Select a topic such as String, Array, Math, or JSON. Choose All when you are unsure where an entry belongs or want a wider match.
Try an exact name such as array_key_exists, or a shorter token such as array, json, or part of a syntax example. The search checks names, summaries, signatures, examples, and notes, and combines with the selected category.
Review the syntax line and example, then copy the name or signature if useful. If nothing appears, clear part of the query, remove punctuation, or switch back to All. The search filters existing entries; it does not accept function arguments or produce an execution result.
For example, searching array_key_exists should help locate the entry. Before relying on the distinction between a missing key and a key whose value is null, read the official array_key_exists documentation and compare it with the behavior you need.
Use cases
See how the tool fits into real work and everyday tasks.
When reviewing a PHP file, search the function name to see a recorded signature and a compact example. Use that information to identify what to verify in the project’s own runtime and official documentation.
When learning string or array operations, select the relevant category and compare nearby entries. The summaries can point you toward a function name, while the official manual supplies fuller explanations and version detail.
Copy a function name or signature into a code review or personal notes. Because the copied line is a reference snippet and not tested code, confirm its types and edge cases before adding it to an application.
Q&A
Find concise answers to common questions and confusing cases.
No. It filters and displays stored reference entries. It does not execute the text you enter, evaluate arguments, or show a program’s output.
The controls are English, but many stored record summaries and notes are Chinese. Search by the PHP name or syntax when possible, then use the linked official PHP manual page for an English explanation.
The index is curated and does not include every PHP function, method, language construct, or extension entry. Try a shorter keyword or All category; if the item is still missing, consult the official manual’s function index.
No. Entries do not have a PHP version selector, and the recorded syntax and examples have not been verified for every version or executed. Confirm parameter changes, deprecations, and extension requirements against the manual for your target environment.
Notes
Review scope, result limitations, and important precautions before use.
Descriptions, syntax lines, and snippets are reference material, not a compatibility check or working implementation guarantee. PHP behavior can depend on the version in use, installed extensions, configuration, argument values, and surrounding code. In particular, review functions related to files, network requests, sessions, input handling, and cryptography with the relevant security and error-handling requirements in mind.
Use the official manual as the authority for current behavior and test code in the same PHP version and extension setup as the intended application. A copied snippet may omit validation, error handling, or context-specific safeguards.
Related
Discover related tools, collections, and available API capabilities.