无需言 做自己 业 ,精于勤 荒于嬉.
- 杂项 函数 __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_string 字符串的语法高亮
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php highlight_string('<?php phpinfo(); ?>'); ?>
- 杂项 函数 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.'; ?>
- 杂项 函数 hrtime 获取系统的高精度时间
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php echo hrtime(true), PHP_EOL; print_r(hrtime()); ?>
- 杂项 函数 pack 将数据打包成二进制字符串
-
发表日期:2021-07-01 10:15:42 | 来源: | 分类:杂项 函数
-
示例1
<?php $binarydata = pack("nvc*", 0x1234, 0x5678, 65, 66); ?>
- SimpleXML 函数 simplexml_import_dom Get a SimpleXMLElement object from a DOM node
-
发表日期:2021-07-01 08:57:25 | 来源: | 分类:SimpleXML 函数
-
示例1
<?php $dom = new DOMDocument; $dom->loadXML('<books><book><title>blah</title></book></books>'); if (!$dom) { echo 'Error while parsing the document'; exit; } $s = simplexml_import_dom($dom); echo $s->book[0]->title; ?>
- SimpleXML 函数 simplexml_load_string Interprets a string of XML into an object
-
发表日期:2021-07-01 08:57:25 | 来源: | 分类:SimpleXML 函数
-
示例1
<?php $string = <<<XML<?xml version='1.0'?> <document> <title>Forty What?</title> <from>Joe</from> <to>Jane</to> <body> I know that's the answer -- but what's the question? </body></document>XML; $xml = simplexml_load_string($string); print_r($xml); ?>
- SimpleXML 函数 simplexml_load_file Interprets an XML file into an object
-
发表日期:2021-07-01 08:57:25 | 来源: | 分类:SimpleXML 函数
-
示例1
<?php // The file test.xml contains an XML document with a root element// and at least an element /[root]/title.if (file_exists('test.xml')) { $xml = simplexml_load_file('test.xml'); print_r($xml); } else { exit('Failed to open test.xml.'); } ?>
- 变量处理 函数 is_float 检测变量是否是浮点型
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
is_float
(PHP 4, PHP 5, PHP 7, PHP 8)
is_float — 检测变量是否是浮点型
描述
is_float(mixed$var): bool如果
var是 float 则返回true,否则返回false。注意:
若想测试一个变量是否是数字或数字字符串(如表单输入,它们通常为字符串),必须使用 is_numeric()。
参见 is_bool()、is_int()、is_integer()、is_numeric()、is_string()、is_array() 和 is_object()。
- 变量处理 函数 is_null 检测变量是否为 null
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
is_null
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
is_null — 检测变量是否为
null描述
is_null(mixed$var): bool如果
var是 null 则返回true,否则返回false。查看
null类型获知变量什么时候被认为是null,而什么时候不是。参见
null、is_bool()、is_numeric()、is_float()、is_int()、is_string()、is_object()、is_array()、is_integer() 和 is_real()。
- 变量处理 函数 is_object 检测变量是否是一个对象
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
is_object
(PHP 4, PHP 5, PHP 7, PHP 8)
is_object — 检测变量是否是一个对象
描述
is_object(mixed$var): bool如果
var是一个 object 则返回true,否则返回false。参见 is_bool()、is_int()、is_integer()、is_float()、is_string() 和 is_array()。
- 变量处理 函数 is_resource 检测变量是否为资源类型
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
is_resource
(PHP 4, PHP 5, PHP 7, PHP 8)
is_resource — 检测变量是否为资源类型
描述
is_resource(mixed$var): bool如果给出的参数
var是 resource 类型,is_resource() 返回true,否则返回false。查看 resource 类型文档获取更多的信息。
- 变量处理 函数 is_string 检测变量是否是字符串
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
is_string
(PHP 4, PHP 5, PHP 7, PHP 8)
is_string — 检测变量是否是字符串
描述
is_string(mixed$var): bool如果
var是 string 则返回true,否则返回false。参见 is_bool()、is_int()、is_integer()、is_float()、is_real()、is_object() 和 is_array()。
- 变量处理 函数 is_long is_int() 的别名
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
- 变量处理 函数 isset 检测变量是否已设置并且非 null
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
示例1
<?php $var = ''; // 结果为 TRUE,所以后边的文本将被打印出来。if (isset($var)) { echo "This var is set so I will print."; } // 在后边的例子中,我们将使用 var_dump 输出 isset() 的返回值。// the return value of isset().$a = "test"; $b = "anothertest"; var_dump(isset($a)); // TRUEvar_dump(isset($a, $b)); // TRUEunset ($a); var_dump(isset($a)); // FALSEvar_dump(isset($a, $b)); // FALSE$foo = NULL; var_dump(isset($foo)); // FALSE?>示例2
<?php $a = array ('test' => 1, 'hello' => NULL, 'pie' => array('a' => 'apple')); var_dump(isset($a['test'])); // TRUEvar_dump(isset($a['foo'])); // FALSEvar_dump(isset($a['hello'])); // FALSE// 键 'hello' 的值等于 NULL,所以被认为是未置值的。// 如果想检测 NULL 键值,可以试试下边的方法。 var_dump(array_key_exists('hello', $a)); // TRUE// Checking deeper array valuesvar_dump(isset($a['pie']['a'])); // TRUEvar_dump(isset($a['pie']['b'])); // FALSEvar_dump(isset($a['cake']['a']['b'])); // FALSE?>示例3
<?php $expected_array_got_string = 'somestring'; var_dump(isset($expected_array_got_string['some_key'])); var_dump(isset($expected_array_got_string[0])); var_dump(isset($expected_array_got_string['0'])); var_dump(isset($expected_array_got_string[0.5])); var_dump(isset($expected_array_got_string['0.5'])); var_dump(isset($expected_array_got_string['0 Mostel'])); ?>
- 变量处理 函数 print_r 以易于理解的格式打印变量。
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
示例1
<pre><?php $a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z')); print_r ($a); ?></pre>示例2
<?php $b = array ('m' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y', 'z')); $results = print_r($b, true); // $results 包含了 print_r 的输出?>
- 变量处理 函数 settype 设置变量的类型
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
示例1
<?php $foo = "5bar"; // string$bar = true; // booleansettype($foo, "integer"); // $foo 现在是 5 (integer)settype($bar, "string"); // $bar 现在是 "1" (string)?>
- 变量处理 函数 serialize 产生一个可存储的值的表示
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
示例1
<?php // $session_data 是包含了当前用户 session 信息的多维数组。// 我们使用 serialize() 在请求结束之前将其存储到数据库中。$conn = odbc_connect ("webdb", "php", "chicken"); $stmt = odbc_prepare ($conn, "UPDATE sessions SET data = ? WHERE id = ?"); $sqldata = array (serialize($session_data), $PHP_AUTH_USER); if (!odbc_execute ($stmt, &$sqldata)) { $stmt = odbc_prepare($conn, "INSERT INTO sessions (id, data) VALUES(?, ?)"); if (!odbc_execute($stmt, &$sqldata)) { /* 出错 */ } } ?>
- 变量处理 函数 is_scalar 检测变量是否是一个标量
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
示例1
<?php function show_var($var){ if (is_scalar($var)) { echo $var; } else { var_dump($var); } } $pi = 3.1416; $proteins = array("hemoglobin", "cytochrome c oxidase", "ferredoxin"); show_var($pi); show_var($proteins)?>
- 变量处理 函数 unset 释放给定的变量
-
发表日期:2021-07-01 08:57:22 | 来源: | 分类:变量处理 函数
-
示例1
<?php function destroy_foo() { global $foo; unset($foo); } $foo = 'bar'; destroy_foo(); echo $foo; ?>示例2
<?php function foo() { unset($GLOBALS['bar']); } $bar = "something"; foo(); ?>示例3
<?php function foo(&$bar) { unset($bar); $bar = "blah"; } $bar = 'something'; echo "$bar\n"; foo($bar); echo "$bar\n"; ?>示例4
<?php function foo(){ static $bar; $bar++; echo "Before unset: $bar, "; unset($bar); $bar = 23; echo "after unset: $bar\n"; } foo(); foo(); foo(); ?>示例5
<?php // 销毁单个变量unset ($foo); // 销毁单个数组元素unset ($bar['quux']); // 销毁一个以上的变量unset($foo1, $foo2, $foo3); ?>
示例6
<?php $name = 'Felipe'; var_dump((unset) $name); var_dump($name); ?>
- 前端开发(1)
- 数据库(0)
- PHP(0)
- 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)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号