杂项 函数 业 ,精于勤 荒于嬉.
- 杂项 函数 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]); } ?>
- 杂项 函数 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_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'); ?>
- 杂项 函数 show_source 别名 highlight_file()
-
发表日期:2021-07-01 10:15:44 | 来源: | 分类:杂项 函数
-
说明
此函数是该函数的别名: highlight_file().
- 杂项 函数 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"; ?>
- 杂项 函数 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.'); } ?>
- 杂项 函数 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."; } ?>
- 杂项 函数 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)); ?>
- 杂项 函数 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)); ?>
- 杂项 函数 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"; ?>
- 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)