杂项 函数 业 ,精于勤 荒于嬉.

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

参见

阅读全文 »

杂项 函数 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!"?>

阅读全文 »

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

阅读全文 »

杂项 函数 defined 检查某个名称的常量是否存在

发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数

      示例1
<?php 
/* 注意引号的使用,这很重要。   这个例子是检查 * 如果字符串 'TEST' 是 TEST 常量的名称 */
if (defined('TEST')) {
    echo TEST;
}
?>

阅读全文 »

杂项 函数 die 等同于 exit()

发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数

die

(PHP 4, PHP 5, PHP 7, PHP 8)

die等同于 exit()

说明

语法结构等同于 exit()

阅读全文 »

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

阅读全文 »

杂项 函数 exit 输出一个消息并且退出当前脚本

发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数

      示例1
<?php 
$filename = '/path/to/data-file';
$file = fopen($filename, 'r')    or exit("unable to open file ($filename)");
?>

      示例2
<?php 
//exit program normallyexit;
exit();
exit(0);
//exit with an error codeexit(1);
exit(0376);
 //octal?>

      示例3
<?php 
class Foo{
    public function __destruct()    {
        echo 'Destruct: ' . __METHOD__ . '()' . PHP_EOL;
    }
}
function shutdown(){
    echo 'Shutdown: ' . __FUNCTION__ . '()' . PHP_EOL;
}
$foo = new Foo();
register_shutdown_function('shutdown');
exit();
echo 'This will not be output.';
?>

阅读全文 »

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

阅读全文 »

杂项 函数 __halt_compiler 中断编译器的执行

发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数

      示例1
<?php 
// open this file$fp = fopen(__FILE__, 'r');
// seek file pointer to datafseek($fp, __COMPILER_HALT_OFFSET__);
// and output itvar_dump(stream_get_contents($fp));
// the end of the script execution__halt_compiler();
 the installation data (eg. tar, gz, PHP, etc.)

阅读全文 »

杂项 函数 highlight_file 语法高亮一个文件

发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数

      示例1
AddType application/x-httpd-php-source .phps

阅读全文 »

杂项 函数 highlight_string 字符串的语法高亮

发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数

      示例1
<?php 
highlight_string('<?php phpinfo();
 ?>');
?>

阅读全文 »

杂项 函数 hrtime 获取系统的高精度时间

发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数

      示例1
<?php 
echo hrtime(true), PHP_EOL;
print_r(hrtime());
?>

阅读全文 »

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

阅读全文 »

杂项 函数 pack 将数据打包成二进制字符串

发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数

      示例1
<?php 
$binarydata = pack("nvc*", 0x1234, 0x5678, 65, 66);
?>

阅读全文 »

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

阅读全文 »

杂项 函数 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.

参见

阅读全文 »

杂项 函数 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_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.

参见

阅读全文 »

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

参见

阅读全文 »

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