杂项 函数 业 ,精于勤 荒于嬉.
- 杂项 函数 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处理连接的详情。
- 杂项 函数 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 | 来源: | 分类:杂项 函数
- 杂项 函数 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_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() - 字符串按要求的字符编码来转换
-
- 杂项 函数 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_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
- 杂项 函数 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
-
- 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)
宁公网安备 64010402001209号