无需言 做自己 业 ,精于勤 荒于嬉.
- 字符串 函数 chr 返回指定的字符
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php $str = "The string ends in escape: "; $str .= chr(27); /* 在 $str 后边增加换码符 */ /* 通常这样更有用 */ $str = sprintf("The string ends in escape: %c", 27); ?>
- 字符串 函数 addslashes 使用反斜线引用字符串
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php $str = "Is your name O'reilly?"; // 输出: Is your name O\'reilly? echo addslashes($str); ?>
- 字符串 函数 bin2hex 函数把包含数据的二进制字符串转换为十六进制值
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
- 字符串 函数 chunk_split 将字符串分割成小块
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php // 使用 RFC 2045 语义格式化 $data$new_string = chunk_split(base64_encode($data)); ?>
- 字符串 函数 addcslashes 以 C 语言风格使用反斜线转义字符串中的字符
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php echo addcslashes('foo[ ]', 'A..z'); // 输出:\f\o\o\[ \]示例2
// 所有大小写字母均被转义
示例3
// ... 但 [\]^_` 以及分隔符、换行符、回车符等也一并被转义了。
示例4
?>
示例5
<?php echo addcslashes("zoo['.']", 'z..A'); // 输出:\zoo['\.']示例6
?>
示例7
<?php $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377"); ?>
- 字符串 函数 convert_uuencode 使用 uuencode 编码一个字符串
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php $some_string = "test\ntext text\r\n"; echo convert_uuencode($some_string); ?>
- 字符串 函数 chop rtrim() 的别名
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
- 字符串 函数 crc32 计算一个字符串的 crc32 多项式
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php $checksum = crc32("The quick brown fox jumped over the lazy dog."); printf("%u\n", $checksum); ?>
- 字符串 函数 convert_uudecode 解码一个 uuencode 编码的字符串
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php /* 你猜会输出啥?:) */ echo convert_uudecode("+22!L; W9E(%!(4\"$`\n`"); ?>
- 字符串 函数 echo 输出一个或多个字符串
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
I have <?=$foo?> foo.
示例2
<?php echo "Hello World"; // Strings can either be passed individually as multiple arguments or// concatenated together and passed as a single argumentecho 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10); echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n"; // Because echo does not behave like a function, the following code is invalid.($some_var) ? echo 'true' : echo 'false'; // However, the following examples will work:($some_var) ? print 'true' : print 'false'; // print is also a construct, but // it behaves like a function, so // it may be used in this context.echo $some_var ? 'true': 'false'; // changing the statement around?>
示例3
<?php echo "Sum: ", 1 + 2; echo "Hello ", isset($name) ? $name : "John Doe", "!";
示例4
<?php echo 'Sum: ' . (1 + 2); echo 'Hello ' . (isset($name) ? $name : 'John Doe') . '!';
- 字符串 函数 convert_cyr_string 将字符由一种 Cyrillic 字符转换成另一种
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
convert_cyr_string
(PHP 4, PHP 5, PHP 7)
convert_cyr_string — 将字符由一种 Cyrillic 字符转换成另一种
说明
convert_cyr_string(string$str, string$from, string$to): string此函数将给定的字符串从一种 Cyrillic 字符转换成另一种,返回转换之后的字符串。
参数
-
str -
要转换的字符。
-
from -
单个字符,代表源 Cyrillic 字符集。
-
to -
单个字符,代表了目标 Cyrillic 字符集。
支持的类型有:
- k - koi8-r
- w - windows-1251
- i - iso8859-5
- a - x-cp866
- d - x-cp866
- m - x-mac-cyrillic
返回值
返回转换后的字符串。
注释
注意: 此函数可安全用于二进制对象。
-
- 字符串 函数 explode 使用一个字符串分割另一个字符串
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php // 示例 1$pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); echo $pieces[0]; // piece1echo $pieces[1]; // piece2// 示例 2$data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user; // fooecho $pass; // *?>示例2
<?php /* 字符串内不包含分隔字符时, 会简单返回只有一个原始字符串元素的 array。*/ $input1 = "hello"; $input2 = "hello,there"; $input3 = ','; var_dump( explode( ',', $input1 ) ); var_dump( explode( ',', $input2 ) ); var_dump( explode( ',', $input3 ) ); ?>
示例3
<?php $str = 'one|two|three|four'; // 正数的 limitprint_r(explode('|', $str, 2)); // 负数的 limitprint_r(explode('|', $str, -1)); ?>
- 字符串 函数 fprintf 将格式化后的字符串写入到流
-
发表日期:2021-07-01 10:23:20 | 来源: | 分类:字符串 函数
-
示例1
<?php if (!($fp = fopen('date.txt', 'w'))) { return; } fprintf($fp, "%04d-%02d-%02d", $year, $month, $day); // will write the formatted ISO date to date.txt?>示例2
<?php if (!($fp = fopen('currency.txt', 'w'))) { return; } $money1 = 68.75; $money2 = 54.35; $money = $money1 + $money2; // echo $money will output "123.1"; $len = fprintf($fp, '%01.2f', $money); // will write "123.10" to currency.txtecho "wrote $len bytes to currency.txt"; // use the return value of fprintf to determine how many bytes we wrote?>
- 错误处理 函数 预定义常量
-
发表日期:2021-07-01 10:18:48 | 来源: | 分类:错误处理 函数
-
预定义常量
下列常量作为 PHP 核心的一部分总是可用的。
注意: 你可以使用它们在中的常量名称; 但是在 PHP 之外,例如在之中, 你必须使用二进制位掩码来代替。
错误和日志记录 值 常量 说明 备注 1 E_ERROR(int)致命的运行时错误。这类错误一般是不可恢复的情况,例如内存分配导致的问题。后果是导致脚本终止不再继续运行。 2 E_WARNING(int)运行时警告 (非致命错误)。仅给出提示信息,但是脚本不会终止运行。 4 E_PARSE(int)编译时语法解析错误。解析错误仅仅由分析器产生。 8 E_NOTICE(int)运行时通知。表示脚本遇到可能会表现为错误的情况,但是在可以正常运行的脚本里面也可能会有类似的通知。 16 E_CORE_ERROR(int)在 PHP 初始化启动过程中发生的致命错误。该错误类似 E_ERROR,但是是由 PHP 引擎核心产生的。32 E_CORE_WARNING(int)PHP 初始化启动过程中发生的警告 (非致命错误) 。类似 E_WARNING,但是是由 PHP 引擎核心产生的。64 E_COMPILE_ERROR(int)致命编译时错误。类似 E_ERROR,但是是由 Zend 脚本引擎产生的。128 E_COMPILE_WARNING(int)编译时警告 (非致命错误)。类似 E_WARNING,但是是由 Zend 脚本引擎产生的。256 E_USER_ERROR(int)用户产生的错误信息。类似 E_ERROR,但是是由用户自己在代码中使用 PHP 函数 trigger_error()来产生的。512 E_USER_WARNING(int)用户产生的警告信息。类似 E_WARNING,但是是由用户自己在代码中使用 PHP 函数 trigger_error()来产生的。1024 E_USER_NOTICE(int)用户产生的通知信息。类似 E_NOTICE,但是是由用户自己在代码中使用 PHP 函数 trigger_error()来产生的。2048 E_STRICT(int)启用 PHP 对代码的修改建议,以确保代码具有最佳的互操作性和向前兼容性。 PHP 5.4.0 之前的版本中不包含 E_ALL4096 E_RECOVERABLE_ERROR(int)可被捕捉的致命错误。 它表示发生了一个可能非常危险的错误,但是还没有导致PHP引擎处于不稳定的状态。 如果该错误没有被用户自定义句柄捕获 (参见 set_error_handler()),将成为一个 E_ERROR从而脚本会终止运行。自 PHP 5.2.0 起 8192 E_DEPRECATED(int)运行时通知。启用后将会对在未来版本中可能无法正常工作的代码给出警告。 自 PHP 5.3.0 起 16384 E_USER_DEPRECATED(int)用户产生的警告信息。 类似 E_DEPRECATED, 但是是由用户自己在代码中使用PHP函数 trigger_error()来产生的。自 PHP 5.3.0 起 32767 E_ALL(int)PHP 5.4.0 之前为 E_STRICT除外的所有错误和警告信息。PHP 5.4.x 中为 32767, PHP 5.3.x 中为 30719, PHP 5.2.x 中为 6143, 更早之前的 PHP 版本中为 2047。 上面的值(数值或者符号)用于建立一个二进制位掩码,来制定要报告的错误信息。
可以使用 按位运算符 来组合这些值或者屏蔽某些类型的错误。请注意,在之中,只有'|', '~', '!', '^' 和 '&' 会正确解析。
- 杂项 函数 show_source 别名 highlight_file()
-
发表日期:2021-07-01 10:15:44 | 来源: | 分类:杂项 函数
-
说明
此函数是该函数的别名: highlight_file().
- 杂项 函数 unpack Unpack data from binary string
-
发表日期:2021-07-01 10:15:44 | 来源: | 分类:杂项 函数
-
示例1
<?php $binarydata = "\x04\x00\xa0\x00"; $array = unpack("cchars/nint", $binarydata); print_r($array); ?>示例2
<?php $binarydata = "\x04\x00\xa0\x00"; $array = unpack("c2chars/nint", $binarydata); print_r($array); ?>示例3
<?php $binarydata = "\x32\x42\x00\xa0"; $array = unpack("c2/n", $binarydata); var_dump($array); ?>
- 杂项 函数 usleep 以指定的微秒数延迟执行
-
发表日期:2021-07-01 10:15:44 | 来源: | 分类:杂项 函数
-
示例1
<?php // Current timeecho date('h:i:s') . "\n"; // wait for 2 secondsusleep(2000000); // back!echo date('h:i:s') . "\n"; ?>
- 杂项 函数 die 等同于 exit()
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
- 杂项 函数 ignore_user_abort 设置客户端断开连接时是否中断脚本的执行
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php // Ignore user aborts and allow the script// to run foreverignore_user_abort(true); set_time_limit(0); echo 'Testing connection handling in PHP'; // Run a pointless loop that sometime // hopefully will make us click away from // page or click the "Stop" button.while(1){ // Did the connection fail? if(connection_status() != CONNECTION_NORMAL) { break; } // Sleep for 10 seconds sleep(10); } // If this is reached, then the 'break' // was triggered from inside the while loop// So here we can log, or perform any other tasks// we need without actually being dependent on the // browser.?>
- 杂项 函数 sapi_windows_cp_get Get current codepage
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
sapi_windows_cp_get
(PHP 7 >= 7.1.0, PHP 8)
sapi_windows_cp_get — Get current codepage
说明
sapi_windows_cp_get(string$kind= ""): intGets the current codepage.
参数
-
kind -
The kind of operating system codepage to get, either
'ansi'or'oem'. Any other value refers to the current codepage of the process.
返回值
If
kindis'ansi', the current ANSI code page of the operating system is returned. Ifkindis'oem', the current OEM code page of the operating system is returned. Otherwise, the current codepage of the process is returned.参见
- sapi_windows_cp_set() - Set process codepage
-
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号