无需言 做自己 业 ,精于勤 荒于嬉.

杂项 函数 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_getGet current codepage

说明

sapi_windows_cp_get(string $kind = ""): int

Gets 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 kind is 'ansi', the current ANSI code page of the operating system is returned. If kind is 'oem', the current OEM code page of the operating system is returned. Otherwise, the current codepage of the process is returned.

参见

阅读全文 »

杂项 函数 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_convConvert string from one codepage to another

说明

sapi_windows_cp_conv(int|string $in_codepage, int|string $out_codepage, string $subject): string

Convert string from one codepage to another.

参数

in_codepage

The codepage of the subject string. Either the codepage name or identifier.

out_codepage

The codepage to convert the subject string to. Either the codepage name or identifier.

subject

The string to convert.

返回值

The subject string converted to out_codepage, or null on failure.

错误/异常

This function issues E_WARNING level errors, if invalid codepages are given, or if the subject is not valid for in_codepage.

参见

阅读全文 »

杂项 函数 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_setSet process codepage

说明

sapi_windows_cp_set(int $cp): bool

Set the codepage of the current process.

参数

cp

A codepage identifier.

返回值

成功时返回 true, 或者在失败时返回 false

参见

阅读全文 »

杂项 函数 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_utf8Indicates whether the codepage is UTF-8 compatible

说明

sapi_windows_cp_is_utf8(): bool

Indicates whether the codepage of the current process is UTF-8 compatible.

参数

此函数没有参数。

返回值

Returns whether the codepage of the current process is UTF-8 compatible.

参见

阅读全文 »

杂项 函数 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 定义的常量来确定连接状态。

参见

阅读全文 »

杂项 函数 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);
?>

阅读全文 »

全部博文(1590)
集速网 copyRight © 2015-2025 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。