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 .
If this tool helped you, you can buy us a coffee ☕
Enter a PHP function name to quickly look up its description, parameters, and return values online.
获取字符串的字节长度,注意中文 UTF-8 下一个汉字占 3 字节。
strlen(string $string): intstrlen('hello') // 5按多字节字符获取字符串长度,支持 UTF-8 等编码。
mb_strlen(string $string, ?string $encoding = null): intmb_strlen('你好世界', 'UTF-8') // 4查找子串在字符串中第一次出现的位置,未找到返回 false。
strpos(string $haystack, string $needle, int $offset = 0): int|falsestrpos('hello world', 'world') // 6不区分大小写的 strpos 变体。
stripos(string $haystack, string $needle, int $offset = 0): int|falsestripos('Hello', 'e') // 1在字符串中查找并替换内容,支持数组批量替换。
str_replace(array|string $search, array|string $replace, string|array $subject, int &$count = null): string|arraystr_replace('foo', 'bar', 'foobar') // 'barbar'按正则模式查找并替换字符串。
preg_replace(string|array $pattern, string|array $replacement, string|array $subject): string|array|nullpreg_replace('/\\d+/', '#', 'abc123') // 'abc#'截取字符串的一部分,按字节计算。
substr(string $string, int $offset, ?int $length = null): stringsubstr('hello', 1, 3) // 'ell'按多字节字符截取字符串。
mb_substr(string $string, int $start, ?int $length = null, ?string $encoding = null): stringmb_substr('你好世界', 0, 2) // '你好'去除字符串首尾的空白字符或指定字符。
trim(string $string, string $characters = " \t\n\r\0\x0B"): stringtrim(' hi ') // 'hi'去除字符串左侧空白或指定字符。
ltrim(string $string, string $characters = " \t\n\r\0\x0B"): stringltrim(' hi') // 'hi'去除字符串右侧空白或指定字符。
rtrim(string $string, string $characters = " \t\n\r\0\x0B"): stringrtrim('hi ') // 'hi'将字符串中的 ASCII 字母转换为小写。
strtolower(string $string): stringstrtolower('Hello') // 'hello'将字符串中的 ASCII 字母转换为大写。
strtoupper(string $string): stringstrtoupper('Hello') // 'HELLO'将字符串首字母转大写。
ucfirst(string $string): stringucfirst('hello world') // 'Hello world'将每个单词的首字母转大写。
ucwords(string $string, string $separators = " \t\r\n\f\v"): stringucwords('hello world') // 'Hello World'按指定分隔符将字符串拆分为数组。
explode(string $separator, string $string, int $limit = PHP_INT_MAX): arrayexplode(',', 'a,b,c') // ['a','b','c']用分隔符拼接数组为字符串,等同于 join。
implode(string $separator, array $array): stringimplode('-', ['a','b','c']) // 'a-b-c'按格式化字符串返回新的字符串,不直接输出。
sprintf(string $format, mixed ...$values): stringsprintf('%05d', 42) // '00042'按千分位与指定小数位格式化数字。
number_format(float $num, int $decimals = 0, string $decimal_separator = '.', string $thousands_separator = ','): stringnumber_format(1234567.891, 2) // '1,234,567.89'将字符串填充到指定长度。
str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT): stringstr_pad('5', 3, '0', STR_PAD_LEFT) // '005'将字符串重复指定次数后返回。
str_repeat(string $string, int $times): stringstr_repeat('ab', 3) // 'ababab'将字符串按固定长度分割为数组。
str_split(string $string, int $length = 1): arraystr_split('hello', 2) // ['he','ll','o']把预定义的字符转换为 HTML 实体,防止 XSS。
htmlspecialchars(string $string, int $flags = ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML401, ?string $encoding = null, bool $double_encode = true): stringhtmlspecialchars('<a>') // '<a>'在字符串的每个换行符前插入 <br> 标签。
nl2br(string $string, bool $use_xhtml = true): stringnl2br("a\nb") // 'a<br />\nb'统计数组元素的个数。
count(Countable|array $value, int $mode = COUNT_NORMAL): intcount([1,2,3]) // 3返回数组的所有键名,可指定值进行过滤。
array_keys(array $array, mixed $filter_value = null, bool $strict = false): arrayarray_keys(['a'=>1,'b'=>2]) // ['a','b']返回数组中所有值组成的索引数组。
array_values(array $array): arrayarray_values(['a'=>1,'b'=>2]) // [1,2]合并一个或多个数组,相同字符串键后者覆盖前者。
array_merge(array ...$arrays): arrayarray_merge(['a'=>1],['a'=>2,'b'=>3]) // ['a'=>2,'b'=>3]用一个数组的值作为键,另一个数组的值作为值组成新数组。
array_combine(array $keys, array $values): arrayarray_combine(['a','b'],[1,2]) // ['a'=>1,'b'=>2]对数组每个元素应用回调函数并返回新数组。
array_map(?callable $callback, array $array, array ...$arrays): arrayarray_map(fn($n)=>$n*2,[1,2,3]) // [2,4,6]用回调函数过滤数组元素,保留返回 true 的项。
array_filter(array $array, ?callable $callback = null, int $mode = 0): arrayarray_filter([0,1,2,'',3]) // [1=>1,2=>2,4=>3]用回调函数迭代地将数组归约为单一值。
array_reduce(array $array, callable $callback, mixed $initial = null): mixedarray_reduce([1,2,3], fn($c,$i)=>$c+$i, 0) // 6在数组中搜索给定值,返回第一个匹配的键,未找到返回 false。
array_search(mixed $needle, array $haystack, bool $strict = false): int|string|falsearray_search('b', ['a','b','c']) // 1检查值是否存在于数组中。
in_array(mixed $needle, array $haystack, bool $strict = false): boolin_array(2, [1,2,3]) // true检查数组中是否存在指定的键名。
array_key_exists(string|int $key, array $array): boolarray_key_exists('a', ['a'=>null]) // true去除数组中重复的值。
array_unique(array $array, int $flags = SORT_STRING): arrayarray_unique([1,2,2,3]) // [0=>1,1=>2,3=>3]从数组中取出一段,类似 JavaScript 的 slice。
array_slice(array $array, int $offset, ?int $length = null, bool $preserve_keys = false): arrayarray_slice([1,2,3,4,5], 1, 2) // [2,3]移除数组的一部分并用其他元素替换。
array_splice(array &$array, int $offset, ?int $length = null, mixed $replacement = []): array$a=[1,2,3]; array_splice($a, 1, 1, ['x','y']); // $a=[1,'x','y',3]返回元素顺序相反的数组。
array_reverse(array $array, bool $preserve_keys = false): arrayarray_reverse([1,2,3]) // [3,2,1]交换数组中的键与值。
array_flip(array $array): arrayarray_flip(['a'=>1,'b'=>2]) // [1=>'a',2=>'b']计算数组之间的差集(值比较)。
array_diff(array $array, array ...$arrays): arrayarray_diff([1,2,3],[2,4]) // [0=>1,2=>3]计算数组之间的交集(值比较)。
array_intersect(array $array, array ...$arrays): arrayarray_intersect([1,2,3],[2,3,4]) // [1=>2,2=>3]向数组末尾插入一个或多个元素。
array_push(array &$array, mixed ...$values): int$a=[1]; array_push($a, 2, 3); // $a=[1,2,3]弹出数组末尾的元素。
array_pop(array &$array): mixed$a=[1,2,3]; array_pop($a); // 返回 3, $a=[1,2]移除数组开头的元素并返回。
array_shift(array &$array): mixed$a=[1,2,3]; array_shift($a); // 返回 1, $a=[2,3]在数组开头插入一个或多个元素。
array_unshift(array &$array, mixed ...$values): int$a=[2,3]; array_unshift($a, 1); // $a=[1,2,3]对数组按值升序排序,重置键。
sort(array &$array, int $flags = SORT_REGULAR): bool$a=[3,1,2]; sort($a); // $a=[1,2,3]对数组按值降序排序,重置键。
rsort(array &$array, int $flags = SORT_REGULAR): bool$a=[1,3,2]; rsort($a); // $a=[3,2,1]使用用户自定义比较函数对数组进行排序。
usort(array &$array, callable $callback): boolusort($a, fn($x,$y)=>$x<=>$y);按键名升序对数组进行排序。
ksort(array &$array, int $flags = SORT_REGULAR): boolksort($arr);从二维数组中获取一列的值。
array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): arrayarray_column($rows, 'name', 'id')返回数字的绝对值。
abs(int|float $num): int|floatabs(-5) // 5对浮点数进行四舍五入。
round(int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): floatround(1.555, 2) // 1.56对浮点数向上取整。
ceil(int|float $num): floatceil(1.2) // 2对浮点数向下取整。
floor(int|float $num): floatfloor(1.8) // 1返回参数中的最大值,支持数组与多个值。
max(mixed $value, mixed ...$values): mixedmax(1, 3, 2) // 3返回参数中的最小值。
min(mixed $value, mixed ...$values): mixedmin([4,2,5]) // 2返回 base 的 exp 次方。
pow(mixed $num, mixed $exponent): int|floatpow(2, 10) // 1024返回数字的平方根。
sqrt(float $num): floatsqrt(16) // 4生成一个伪随机整数。
rand(int $min, int $max): intrand(1, 100)更快、质量更好的伪随机整数生成器。
mt_rand(int $min, int $max): intmt_rand(0, 9999)生成密码学安全的伪随机整数。
random_int(int $min, int $max): intrandom_int(100000, 999999) // 用于验证码通过字符串或浮点获取整数值。
intval(mixed $value, int $base = 10): intintval('42abc') // 42通过字符串获取浮点数值。
floatval(mixed $value): floatfloatval('3.14abc') // 3.14返回当前 Unix 时间戳(秒)。
time(): inttime() // 1700000000返回当前 Unix 时间戳的毫秒部分与秒。
microtime(bool $as_float = false): string|floatmicrotime(true) // 1700000000.1234按格式化字符串返回本地日期与时间。
date(string $format, ?int $timestamp = null): stringdate('Y-m-d H:i:s') // '2024-01-01 12:00:00'由具体日期时间分量生成 Unix 时间戳。
mktime(int $hour = ..., int $minute = ..., int $second = ..., int $month = ..., int $day = ..., int $year = ...): int|falsemktime(0, 0, 0, 1, 1, 2024)将任意英文日期描述解析为时间戳。
strtotime(string $datetime, ?int $baseTimestamp = null): int|falsestrtotime('next monday')对 DateTime 对象按格式化字符串生成字符串。
date_format(DateTimeInterface $object, string $format): stringdate_format(new DateTime, 'Y-m-d')返回两个 DateTime 之间的差值 DateInterval。
date_diff(DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute = false): DateIntervaldate_diff($a, $b)->days校验给定的年月日是否为有效公历日期。
checkdate(int $month, int $day, int $year): boolcheckdate(2, 29, 2024) // true将整个文件读入字符串,也可读取 URL。
file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, ?int $length = null): string|falsefile_get_contents('config.json')将字符串写入文件,文件不存在时自动创建。
file_put_contents(string $filename, mixed $data, int $flags = 0, $context = null): int|falsefile_put_contents('log.txt', $msg, FILE_APPEND)打开文件或 URL 资源,返回文件指针。
fopen(string $filename, string $mode, bool $use_include_path = false, $context = null): resource|false$fp = fopen('data.csv', 'r')关闭一个已打开的文件指针。
fclose(resource $stream): boolfclose($fp)向打开的文件写入数据。
fwrite(resource $stream, string $data, ?int $length = null): int|falsefwrite($fp, 'hello')从文件指针读取指定长度的内容。
fread(resource $stream, int $length): string|falsefread($fp, 1024)从文件指针读取一行。
fgets(resource $stream, ?int $length = null): string|falsewhile ($line = fgets($fp)) { ... }判断文件或目录是否存在。
file_exists(string $filename): boolfile_exists('uploads/avatar.png')判断路径是否为常规文件。
is_file(string $filename): boolis_file('a.txt')判断路径是否为目录。
is_dir(string $filename): boolis_dir('/var/log')创建目录,可递归创建多级路径。
mkdir(string $directory, int $permissions = 0777, bool $recursive = false, $context = null): boolmkdir('a/b/c', 0755, true)删除文件。
unlink(string $filename, $context = null): boolunlink('temp.log')重命名或移动文件、目录。
rename(string $from, string $to, $context = null): boolrename('old.txt', 'new.txt')拷贝文件到目标位置。
copy(string $from, string $to, $context = null): boolcopy('a.png', 'backup/a.png')返回文件大小(字节)。
filesize(string $filename): int|falsefilesize('image.jpg')列出目录中的文件和子目录。
scandir(string $directory, int $sorting_order = SCANDIR_SORT_ASCENDING, $context = null): array|falsescandir('./public')按通配符匹配寻找文件路径。
glob(string $pattern, int $flags = 0): array|falseglob('logs/*.log')返回路径的目录、文件名、扩展名等信息。
pathinfo(string $path, int $flags = PATHINFO_ALL): array|stringpathinfo('/a/b.txt') // ['dirname'=>'/a',...]执行一次正则匹配,匹配成功返回 1。
preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int|falsepreg_match('/^\\d+$/', '123') // 1执行全局正则匹配,匹配多个结果。
preg_match_all(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int|falsepreg_match_all('/\\d+/', 'a1b2c3', $m); // $m[0]=['1','2','3']按正则表达式分割字符串。
preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array|falsepreg_split('/\\s+/', 'a b c') // ['a','b','c']对字符串中的正则特殊字符进行转义。
preg_quote(string $str, ?string $delimiter = null): stringpreg_quote('1+1=2') // '1\\+1=2'检测变量是否声明且不为 null。
isset(mixed $var, mixed ...$vars): boolisset($_GET['id'])检测变量是否为空(0/''/null/false/空数组)。
empty(mixed $var): boolempty($name)销毁变量。
unset(mixed $var, mixed ...$vars): voidunset($tmp)获取变量类型字符串。
gettype(mixed $value): stringgettype([1,2]) // 'array'判断变量是否为数组。
is_array(mixed $value): boolis_array($x)判断变量是否为字符串。
is_string(mixed $value): boolis_string($x)判断变量是否为数字或数字字符串。
is_numeric(mixed $value): boolis_numeric('3.14') // true判断变量是否为 null。
is_null(mixed $value): boolis_null($x)打印变量的详细信息,包括类型与值,常用于调试。
var_dump(mixed ...$values): voidvar_dump($obj)以易读形式打印变量信息,可返回字符串。
print_r(mixed $value, bool $return = false): string|trueprint_r($arr, true)将 PHP 变量编码为 JSON 字符串。
json_encode(mixed $value, int $flags = 0, int $depth = 512): string|falsejson_encode(['a'=>1], JSON_UNESCAPED_UNICODE)将 JSON 字符串解码为 PHP 变量。
json_decode(string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixedjson_decode('{"a":1}', true) // ['a'=>1]返回最近一次 JSON 操作的错误码。
json_last_error(): intif (json_last_error() !== JSON_ERROR_NONE) { ... }对字符串按 application/x-www-form-urlencoded 进行编码。
urlencode(string $string): stringurlencode('hello world') // 'hello+world'对 urlencoded 字符串进行解码。
urldecode(string $string): stringurldecode('a%20b') // 'a b'按 RFC 3986 对字符串进行 URL 编码(空格变 %20)。
rawurlencode(string $string): stringrawurlencode('a b') // 'a%20b'解析 URL,返回各个组成部分。
parse_url(string $url, int $component = -1): array|string|int|null|falseparse_url('https://a.com/b?c=1') // ['scheme'=>'https',...]由数组生成 URL 编码后的查询字符串。
http_build_query(array|object $data, string $numeric_prefix = '', ?string $arg_separator = null, int $encoding_type = PHP_QUERY_RFC1738): stringhttp_build_query(['a'=>1,'b'=>2]) // 'a=1&b=2'对字符串进行 Base64 编码。
base64_encode(string $string): stringbase64_encode('hello') // 'aGVsbG8='对 Base64 字符串进行解码。
base64_decode(string $string, bool $strict = false): string|falsebase64_decode('aGVsbG8=') // 'hello'计算字符串的 MD5 散列值(32 位十六进制)。
md5(string $string, bool $binary = false): stringmd5('hello') // '5d41402abc4b2a76b9719d911017c592'计算字符串的 SHA1 散列值。
sha1(string $string, bool $binary = false): stringsha1('hello')通用散列函数,支持多种算法。
hash(string $algo, string $data, bool $binary = false): stringhash('sha256', $data)使用 HMAC 算法生成带密钥的散列。
hash_hmac(string $algo, string $data, string $key, bool $binary = false): stringhash_hmac('sha256', $data, $secret)用安全的算法(bcrypt/argon2)生成密码哈希。
password_hash(string $password, string|int|null $algo, array $options = []): stringpassword_hash($pw, PASSWORD_DEFAULT)校验密码是否匹配 password_hash 生成的哈希。
password_verify(string $password, string $hash): boolpassword_verify($input, $stored)计算字符串的 CRC32 校验和。
crc32(string $string): intcrc32('hello')初始化一个 cURL 会话。
curl_init(?string $url = null): CurlHandle|false$ch = curl_init('https://api.example.com')设置 cURL 会话选项。
curl_setopt(CurlHandle $handle, int $option, mixed $value): boolcurl_setopt($ch, CURLOPT_RETURNTRANSFER, true)执行 cURL 会话并返回结果。
curl_exec(CurlHandle $handle): string|bool$body = curl_exec($ch)关闭 cURL 会话并释放资源。
curl_close(CurlHandle $handle): voidcurl_close($ch)发送原始 HTTP 头到客户端,须在任何输出之前调用。
header(string $header, bool $replace = true, int $response_code = 0): voidheader('Content-Type: application/json')向客户端发送 Cookie。
setcookie(string $name, string $value = '', int $expires_or_options = 0, string $path = '', string $domain = '', bool $secure = false, bool $httponly = false): boolsetcookie('uid', $uid, time()+3600, '/', '', true, true)启动新会话或恢复现有会话。
session_start(array $options = []): boolsession_start()销毁当前会话的全部数据。
session_destroy(): boolsession_destroy()获取或设置当前会话 ID。
session_id(?string $id = null): string|falsesession_id()更新当前会话 ID 并可选删除旧会话。
session_regenerate_id(bool $delete_old_session = false): boolsession_regenerate_id(true)检查类是否已定义。
class_exists(string $class, bool $autoload = true): boolclass_exists('App\\User')返回对象所属的类名。
get_class(?object $object = null): stringget_class($user) // 'App\\User'检查类或对象是否存在指定方法。
method_exists(object|string $object_or_class, string $method): boolmethod_exists($obj, 'save')检查对象或类是否存在指定属性。
property_exists(object|string $object_or_class, string $property): boolproperty_exists($user, 'email')判断对象是否是给定类的实例或子类。
is_a(mixed $object_or_class, string $class, bool $allow_string = false): boolis_a($user, User::class)运算符,判断对象是否属于某个类或实现某接口。
$obj instanceof ClassNameif ($e instanceof \Exception) { ... }调用一个回调,包括函数名、闭包或方法数组。
call_user_func(callable $callback, mixed ...$args): mixedcall_user_func([$obj,'method'], $arg)输出消息并终止脚本,与 exit 等价。
die(string|int $status = ''): voiddie('error')终止脚本执行,可输出消息或返回退出码。
exit(string|int $status = ''): voidexit(0)设置 PHP 的错误报告级别。
error_reporting(?int $error_level = null): interror_reporting(E_ALL)获取 php.ini 配置项的值。
ini_get(string $option): string|falseini_get('upload_max_filesize')在运行时修改 php.ini 配置项。
ini_set(string $option, string|int|float|bool|null $value): string|falseini_set('memory_limit', '256M')返回当前运行的 PHP 版本。
phpversion(?string $extension = null): string|falsephpversion() // '8.2.0'判断函数是否已定义。
function_exists(string $function): boolif (function_exists('mb_strlen')) { ... }判断常量是否已被定义。
defined(string $constant_name): booldefined('APP_ENV')定义一个常量。
define(string $constant_name, mixed $value, bool $case_insensitive = false): booldefine('APP_ENV', 'production')让脚本暂停指定秒数。
sleep(int $seconds): intsleep(2)让脚本暂停指定微秒数。
usleep(int $microseconds): voidusleep(500000) // 暂停 0.5 秒When writing PHP code, you often need to quickly confirm the exact usage, parameter order, or return type of a built-in function. However, browsing the official manual or searching the web can be inefficient. This tool provides an instant and accurate PHP function lookup service. Simply enter the function name to get its detailed definition, parameter descriptions, and return value information, helping you maintain an uninterrupted development workflow.
str_replace or array_merge.Example: Enter "array_key_exists", and the output will be:
bool array_key_exists ( mixed $key , array $array ) Parameters: $key - The key to check; $array - The target array. Return Value: Returns TRUE if the key exists, otherwise FALSE.
This tool only supports querying built-in PHP functions. It cannot recognize custom functions or special functions introduced via extensions. The search results are for quick reference only; for edge cases or special scenarios, we still recommend consulting the official documentation. When entering a function name, please do not include parentheses, parameters, or other extra characters to avoid matching failures.
We recommend bookmarking this page as a handy quick-reference manual, especially in development environments without IDE auto-completion, as it can significantly reduce the time spent consulting manuals. Common string processing functions like explode (split a string), implode (join array elements), and substr (extract a substring), as well as array manipulation functions like array_filter and array_map, are among the most frequently searched items.
PHP Code Formatter & Beautifier
Free online PHP code formatter and beautifier. Automatically format, indent, and organize your PHP scripts to improve readability instantly.

JSON to PHP Class Generator
Automatically convert JSON data structures into PHP classes with support for type hinting and nested objects to boost development efficiency.

PHP Password Hash Generator
Generate PHP password_hash values online. Supports BCrypt, Argon2I, and Argon2ID algorithms for secure password storage.

HTML to PHP Converter
Quickly convert HTML code into PHP scripts for dynamic web development. Easily integrate PHP logic and improve code modularity and efficiency.
PHP Code Formatter & Beautifier
Free online PHP code formatter and beautifier. Automatically format, indent, and organize your PHP scripts to improve readability instantly.

JSON to PHP Class Generator
Automatically convert JSON data structures into PHP classes with support for type hinting and nested objects to boost development efficiency.

PHP Password Hash Generator
Generate PHP password_hash values online. Supports BCrypt, Argon2I, and Argon2ID algorithms for secure password storage.

HTML to PHP Converter
Quickly convert HTML code into PHP scripts for dynamic web development. Easily integrate PHP logic and improve code modularity and efficiency.

JSON to PHP Array Converter
Quickly convert JSON data into ready-to-use PHP array code. Perfect for API integration and configuration migration.