无需言 做自己 业 ,精于勤 荒于嬉.
- 杂项 函数 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
-
- 杂项 函数 sapi_windows_cp_conv Convert string from one codepage to another
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
sapi_windows_cp_conv
(PHP 7 >= 7.1.0, PHP 8)
sapi_windows_cp_conv — Convert string from one codepage to another
说明
sapi_windows_cp_conv(int|string$in_codepage, int|string$out_codepage, string$subject): stringConvert string from one codepage to another.
参数
-
in_codepage -
The codepage of the
subjectstring. Either the codepage name or identifier. -
out_codepage -
The codepage to convert the
subjectstring to. Either the codepage name or identifier. -
subject -
The string to convert.
返回值
The
subjectstring converted toout_codepage, ornullon failure.错误/异常
This function issues E_WARNING level errors, if invalid codepages are given, or if the subject is not valid for
in_codepage.参见
- sapi_windows_cp_get() - Get current codepage
- iconv() - 字符串按要求的字符编码来转换
-
- 杂项 函数 php_strip_whitespace 返回删除注释和空格后的PHP源码
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php // PHP comment here/* * Another PHP comment */ echo php_strip_whitespace(__FILE__); // Newlines are considered whitespace, and are removed too:do_nothing(); ?>
- 杂项 函数 defined 检查某个名称的常量是否存在
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php /* 注意引号的使用,这很重要。 这个例子是检查 * 如果字符串 'TEST' 是 TEST 常量的名称 */ if (defined('TEST')) { echo TEST; } ?>
- 杂项 函数 sapi_windows_set_ctrl_handler Set or remove a CTRL event handler
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php function ctrl_handler(int $event){ switch ($event) { case PHP_WINDOWS_EVENT_CTRL_C: echo "You have pressed CTRL+C\n"; break; case PHP_WINDOWS_EVENT_CTRL_BREAK: echo "You have pressed CTRL+BREAK\n"; break; } } sapi_windows_set_ctrl_handler('ctrl_handler'); while (true); // infinite loop, so the handler can be triggered?>
- 杂项 函数 sapi_windows_cp_set Set process codepage
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
sapi_windows_cp_set
(PHP 7 >= 7.1.0, PHP 8)
sapi_windows_cp_set — Set process codepage
说明
sapi_windows_cp_set(int$cp): boolSet the codepage of the current process.
参数
-
cp -
A codepage identifier.
返回值
成功时返回
true, 或者在失败时返回false。参见
- sapi_windows_cp_get() - Get current codepage
-
- 杂项 函数 sapi_windows_generate_ctrl_event Send a CTRL event to another process
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php // forward CTRL+BREAK events to the child processsapi_windows_set_ctrl_handler('sapi_windows_generate_ctrl_event'); // create a child process which echoes every second$cmd = ['php', '-r', 'while (true) { echo "I\'m still alive\n"; sleep(1); } ']; $descspec = array(['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']); $options = ['create_process_group' => true]; $proc = proc_open($cmd, $descspec, $pipes, null, null, $options); while (true) { echo fgets($pipes[1]); } ?>
- 杂项 函数 sleep 延缓执行
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php // current timeecho date('h:i:s') . "\n"; // sleep for 10 secondssleep(10); // wake up !echo date('h:i:s') . "\n"; ?>
- 杂项 函数 sapi_windows_vt100_support Get or set VT100 support for the specified stream associated to an output buffer of a Windows console.
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));"
示例2
php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));" 2>NUL
示例3
php -r "var_export(sapi_windows_vt100_support(STDOUT, true));echo ' ';var_export(sapi_windows_vt100_support(STDERR, true));" 2>NUL
示例4
<?php $out = fopen('php://stdout','w'); fwrite($out, 'Just forgot a lettr.'); // Moves the cursor two characters backwardsfwrite($out, "\033[2D"); // Inserts one blank, shifting existing text to the right -> Just forgot a lett r.fwrite($out, "\033[1@"); fwrite($out, 'e'); ?>
- 杂项 函数 time_nanosleep 延缓执行若干秒和纳秒
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php // Careful! This won't work as expected if an array is returnedif (time_nanosleep(0, 500000000)) { echo "Slept for half a second.\n"; } // This is better:if (time_nanosleep(0, 500000000) === true) { echo "Slept for half a second.\n"; } // And this is the best:$nano = time_nanosleep(2, 100000); if ($nano === true) { echo "Slept for 2 seconds, 100 microseconds.\n"; } elseif ($nano === false) { echo "Sleeping failed.\n"; } elseif (is_array($nano)) { $seconds = $nano['seconds']; $nanoseconds = $nano['nanoseconds']; echo "Interrupted by a signal.\n"; echo "Time remaining: $seconds seconds, $nanoseconds nanoseconds."; } ?>
- 杂项 函数 sys_getloadavg 获取系统的负载(load average)
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php $load = sys_getloadavg(); if ($load[0] > 80) { header('HTTP/1.1 503 Too busy, try again later'); die('Server too busy. Please try again later.'); } ?>
- 杂项 函数 sapi_windows_cp_is_utf8 Indicates whether the codepage is UTF-8 compatible
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
sapi_windows_cp_is_utf8
(PHP 7 >= 7.1.0, PHP 8)
sapi_windows_cp_is_utf8 — Indicates whether the codepage is UTF-8 compatible
说明
sapi_windows_cp_is_utf8(): boolIndicates whether the codepage of the current process is UTF-8 compatible.
参数
此函数没有参数。
返回值
Returns whether the codepage of the current process is UTF-8 compatible.
参见
- sapi_windows_cp_get() - Get current codepage
- 杂项 函数 uniqid 生成一个唯一ID
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php /* A uniqid, like: 4b3403665fea6 */ printf("uniqid(): %s\r\n", uniqid()); /* We can also prefix the uniqid, this the same as * doing: * * $uniqid = $prefix . uniqid(); * $uniqid = uniqid($prefix); */ printf("uniqid('php_'): %s\r\n", uniqid('php_')); /* We can also activate the more_entropy parameter, which is * required on some systems, like Cygwin. This makes uniqid() * produce a value like: 4b340550242239.64159797 */ printf("uniqid('', true): %s\r\n", uniqid('', true)); ?>
- 杂项 函数 time_sleep_until 使脚本睡眠到指定的时间为止。
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
<?php //returns false and generates a warningvar_dump(time_sleep_until(time()-1)); // may only work on faster computers, will sleep up to 0.2 secondsvar_dump(time_sleep_until(microtime(true)+0.2)); ?>
- 杂项 函数 connection_aborted 检查客户端是否已经断开
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
connection_aborted
(PHP 4, PHP 5, PHP 7, PHP 8)
connection_aborted — 检查客户端是否已经断开
说明
connection_aborted(): int检查客户端是否已经断开。
返回值
如果客户端已经断开则返回1,否则返回0。
- 杂项 函数 connection_status 返回连接的状态位
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
connection_status
(PHP 4, PHP 5, PHP 7, PHP 8)
connection_status — 返回连接的状态位
说明
connection_status(): int获得当前连接的状态位。
返回值
获得当前连接的状态位, 可以用于与
CONNECTION_XXX定义的常量来确定连接状态。参见
- connection_aborted() - 检查客户端是否已经断开
- ignore_user_abort() - 设置客户端断开连接时是否中断脚本的执行
- 查看连接处理 了解PHP处理连接的详情。
- 杂项 函数 define 定义一个常量
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php define("CONSTANT", "Hello world."); echo CONSTANT; // 输出 "Hello world."echo Constant; // 输出 "Constant" 并导致 Noticedefine("GREETING", "Hello you.", true); echo GREETING; // 输出 "Hello you."echo Greeting; // 输出 "Hello you."// PHP 7 起就可以运行了define('ANIMALS', array( 'dog', 'cat', 'bird')); echo ANIMALS[1]; // 输出 "cat"?>示例2
<?php var_dump(defined('__LINE__')); var_dump(define('__LINE__', 'test')); var_dump(constant('__LINE__')); var_dump(__LINE__); ?>
- 杂项 函数 constant 返回一个常量的值
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php define("MAXSIZE", 100); echo MAXSIZE; echo constant("MAXSIZE"); // 和上行一样interface bar { const test = 'foobar!'; } class foo { const test = 'foobar!'; } $const = 'test'; var_dump(constant('bar::'. $const)); // string(7) "foobar!"var_dump(constant('foo::'. $const)); // string(7) "foobar!"?>
- 杂项 函数 eval 把字符串作为PHP代码执行
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php $string = 'cup'; $name = 'coffee'; $str = 'This is a $string with my $name in it.'; echo $str. "\n"; eval("\$str = \"$str\"; "); echo $str. "\n"; ?>
- 杂项 函数 get_browser 获取浏览器具有的功能
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php echo $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $browser = get_browser(null, true); print_r($browser); ?>
- 前端开发(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大模型(10)
- 其他(0)
宁公网安备 64010402001209号