杂项 函数 业 ,精于勤 荒于嬉.
- 杂项 函数 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
01
<?php
02
define(
"MAXSIZE"
, 100);
03
echo
MAXSIZE;
04
echo
constant(
"MAXSIZE"
);
05
// 和上行一样interface bar {
06
const
test =
'foobar!'
;
07
}
08
class
foo {
09
const
test =
'foobar!'
;
10
}
11
$const
=
'test'
;
12
var_dump(constant(
'bar::'
.
$const
));
13
// string(7) "foobar!"var_dump(constant('foo::'. $const));
14
// string(7) "foobar!"?>
- 杂项 函数 define 定义一个常量
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
01
<?php
02
define(
"CONSTANT"
,
"Hello world."
);
03
echo
CONSTANT;
04
// 输出 "Hello world."echo Constant;
05
// 输出 "Constant" 并导致 Noticedefine("GREETING", "Hello you.", true);
06
echo
GREETING;
07
// 输出 "Hello you."echo Greeting;
08
// 输出 "Hello you."// PHP 7 起就可以运行了define('ANIMALS', array( 'dog', 'cat', 'bird'));
09
echo
ANIMALS[1];
10
// 输出 "cat"?>
示例2
1
<?php
2
var_dump(defined(
'__LINE__'
));
3
var_dump(define(
'__LINE__'
,
'test'
));
4
var_dump(constant(
'__LINE__'
));
5
var_dump(
__LINE__
);
6
?>
- 杂项 函数 defined 检查某个名称的常量是否存在
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
/* 注意引号的使用,这很重要。 这个例子是检查 * 如果字符串 'TEST' 是 TEST 常量的名称 */
3
if
(defined(
'TEST'
)) {
4
echo
TEST;
5
}
6
?>
- 杂项 函数 die 等同于 exit()
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
- 杂项 函数 eval 把字符串作为PHP代码执行
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
$string
=
'cup'
;
3
$name
=
'coffee'
;
4
$str
=
'This is a $string with my $name in it.'
;
5
echo
$str
.
"\n"
;
6
eval
("\
$str
= \"
$str
\";
7
");
8
echo
$str
.
"\n"
;
9
?>
- 杂项 函数 exit 输出一个消息并且退出当前脚本
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
$filename
=
'/path/to/data-file'
;
3
$file
=
fopen
(
$filename
,
'r'
)
or
exit
(
"unable to open file ($filename)"
);
4
?>
示例2
1
<?php
2
//exit program normallyexit;
3
exit
();
4
exit
(0);
5
//exit with an error codeexit(1);
6
exit
(0376);
7
//octal?>
示例3
01
<?php
02
class
Foo{
03
public
function
__destruct() {
04
echo
'Destruct: '
.
__METHOD__
.
'()'
. PHP_EOL;
05
}
06
}
07
function
shutdown(){
08
echo
'Shutdown: '
.
__FUNCTION__
.
'()'
. PHP_EOL;
09
}
10
$foo
=
new
Foo();
11
register_shutdown_function(
'shutdown'
);
12
exit
();
13
echo
'This will not be output.'
;
14
?>
- 杂项 函数 get_browser 获取浏览器具有的功能
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
echo
$_SERVER
[
'HTTP_USER_AGENT'
] .
"\n\n"
;
3
$browser
= get_browser(null, true);
4
print_r(
$browser
);
5
?>
- 杂项 函数 __halt_compiler 中断编译器的执行
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
// open this file$fp = fopen(__FILE__, 'r');
3
// seek file pointer to datafseek($fp, __COMPILER_HALT_OFFSET__);
4
// and output itvar_dump(stream_get_contents($fp));
5
// the end of the script execution__halt_compiler();
6
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
1
<?php
2
highlight_string('<?php phpinfo();
3
?>');
4
?>
- 杂项 函数 hrtime 获取系统的高精度时间
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
echo
hrtime(true), PHP_EOL;
3
print_r(hrtime());
4
?>
- 杂项 函数 ignore_user_abort 设置客户端断开连接时是否中断脚本的执行
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
01
<?php
02
// Ignore user aborts and allow the script// to run foreverignore_user_abort(true);
03
set_time_limit(0);
04
echo
'Testing connection handling in PHP'
;
05
// Run a pointless loop that sometime // hopefully will make us click away from // page or click the "Stop" button.while(1){
06
// Did the connection fail? if(connection_status() != CONNECTION_NORMAL) {
07
break
;
08
}
09
// Sleep for 10 seconds sleep(10);
10
}
11
// 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
1
<?php
2
$binarydata
= pack(
"nvc*"
, 0x1234, 0x5678, 65, 66);
3
?>
- 杂项 函数 php_strip_whitespace 返回删除注释和空格后的PHP源码
-
发表日期:2021-07-01 10:15:43 | 来源: | 分类:杂项 函数
-
示例1
1
<?php
2
// PHP comment here/* * Another PHP comment */
3
echo
php_strip_whitespace(
__FILE__
);
4
// Newlines are considered whitespace, and are removed too:do_nothing();
5
?>
- 杂项 函数 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
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 toout_codepage
, ornull
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
- 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
kind
is'ansi'
, the current ANSI code page of the operating system is returned. Ifkind
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_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)