当前位置: 首页 > news >正文

太仓公司网站建设电话wordpress在本地建站

太仓公司网站建设电话,wordpress在本地建站,wordpress 禁止游客,wordpress 关注微博一 fgets(resource $stream, ?int $length null) 从文件指针中读取一行。 返回字符串,如果文件指针中没有更多的数据了则返回 false。错误发生时返回 false。 $stream 为文件资源,必须指向fopen()或fscokopen()成功打开的文件。文件打开之后&#x…

一 fgets(resource $stream, ?int $length = null)

从文件指针中读取一行。

返回字符串,如果文件指针中没有更多的数据了则返回 false。错误发生时返回 false

$stream 为文件资源,必须指向fopen()或fscokopen()成功打开的文件。文件打开之后,必须使用fclose()关闭

#test.htm
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
……
$file = "test.htm";
$file_obj = fopen($file, "r");
$str = fgets($file_obj, 10);
var_dump($str);#测试结果
string(9) "<!DOCTYPE"

二 fgetss(resource $handle, int $length = ?, string $allowable_tags = ?)

和fgets()相同,但是过滤HTML和PHP标签。返回字符串,错误返回false,文件无内容返回false。

$handle 文件指针

$length 获取字符串长度

$allowable_tags 指定不被去除的标签

自php 7.3.0版本启用,自php 8.0.0起移除。

三 strip_tags(string $string, array|string|null $allowed_tags = null)

从字符串中去除 HTML 和 PHP 标签,机制与fgetss()相同。

参数说明惨开fgetss()。

    $file = "test.htm";$total_lines = 10;$file_obj = fopen($file, "r");$str = "";while (($buffer = fgets($file_obj, 2048)) != false) {$str .= $buffer;if ($total_lines <= 0) {break;}$total_lines--;}var_dump($str);$str = strip_tags($str, "<link>");var_dump($str);

测试结果

string(492) "<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>PHP: fgets - Manual </title><link rel="icon" type="image/svg+xml" sizes="any" href="https://www.php.net/favicon.svg?v=2"><link rel="icon" type="image/png" sizes="196x196" href="https://www.php.net/favicon-196x196.png?v=2">
"
string(244) "PHP: fgets - Manual<link rel="icon" type="image/svg+xml" sizes="any" href="https://www.php.net/favicon.svg?v=2"><link rel="icon" type="image/png" sizes="196x196" href="https://www.php.net/favicon-196x196.png?v=2">
"

四 mb_convert_case(string $string, int $mode, ?string $encoding = null)

对字符串进行大小写转换。大小转换执行根据Unicode字母属性的基础,而strtolower()和strtoupper()使用标准大小写转换。因此函数的行为不受语言环境(locale)设置的影响,能够转换任意具有“字母”属性的字符,例如元音变音A(Ä)。

$mod 可用模式包括:MB_CASE_UPPERMB_CASE_LOWERMB_CASE_TITLEMB_CASE_FOLDMB_CASE_UPPER_SIMPLEMB_CASE_LOWER_SIMPLEMB_CASE_TITLE_SIMPLEMB_CASE_FOLD_SIMPLE。

MB_CASE_UPPER、MB_CASE_UPPER_SIMPLE 全部转大写

MB_CASE_LOWER、MB_CASE_LOWER_SIMPLE 全部转小写

MB_CASE_TITLE、MB_CASE_TITLE_SIMPLE 转为首字母大写

MB_CASE_FOLD、MB_CASE_FOLD_SIMPLE 看起来像全部转小写

$encoding 字体编码

    $str = "qWe asD zxc 123q";var_dump($str);$str = mb_convert_case($str, MB_CASE_UPPER, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_LOWER, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_TITLE, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_FOLD, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_UPPER_SIMPLE, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_LOWER_SIMPLE, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_TITLE_SIMPLE, "GBK");var_dump($str);$str = mb_convert_case($str, MB_CASE_FOLD_SIMPLE, "GBK");var_dump($str);

测试结果

string(16) "qWe asD zxc 123q"
string(16) "QWE ASD ZXC 123Q"
string(16) "qwe asd zxc 123q"
string(16) "Qwe Asd Zxc 123Q"
string(16) "qwe asd zxc 123q"
string(16) "QWE ASD ZXC 123Q"
string(16) "qwe asd zxc 123q"
string(16) "Qwe Asd Zxc 123Q"
string(16) "qwe asd zxc 123q"

五 array_map(?callable $callback, array $array, array ...$arrays)

为数组的每个元素应用回调函数。返回数组,包括callback结果。callback参数与对应处理的数组数量相同,传入多个数组时,返回的数组键是按顺序的 integer。

function dealwitcharr($value1, $value2) {if (is_numeric($value1) && is_numeric($value2)) {return $value1 + $value2;}return $value1 . "&" . $value2;
}    
$arr1 = ['test1', '1', '3', 'test2'];
$arr2 = ['5', '6', 'test1', 'test2'];
$arr = array_map("dealwitcharr", $arr1, $arr2);
var_dump($arr);

 测试结果

array(4) {[0]=>string(7) "test1&5"[1]=>int(7)[2]=>string(7) "3&test1"[3]=>string(11) "test2&test2"
}

六 get_defined_vars()

返回由所有已定义变量所组成的数组。

    $test1 = "123";// ob_end_clean();$arr = get_defined_vars();var_dump($arr);

测试结果

array(1) {       ["test1"]=>    string(3) "123"
}

七 get_debug_type(mixed $value)

该函数会将对象解析为其类名。该函数与 gettype() 的区别在于:它返回的类型名称更符合实际用法,而不是那些出于历史原因而存在的名称。

    echo get_debug_type(null) . PHP_EOL;echo get_debug_type(true) . PHP_EOL;echo get_debug_type(1) . PHP_EOL;echo get_debug_type(0.1) . PHP_EOL;echo get_debug_type("foo") . PHP_EOL;echo get_debug_type([]) . PHP_EOL;echo get_debug_type(new stdClass) . PHP_EOL;echo get_debug_type(new class {}) . PHP_EOL;

测试结果

null
bool
int
float
string
array
stdClass
class@anonymous

八 http_build_query

生成 URL-encode 之后的请求字符串。

参数列表:

  1. data 请求数据,数组或对象。为对象,仅public属性会加入结果。
  2. numeric_perfix 基础数组中的数字下标元素的前缀。PHP 或其它 CGI 程序在稍后对数据进行解码时获取合法的变量名。
  3. arg_separator 参数分隔符。如果未设置或为null。
  4. encoding_type 编码类型,默认PHP_QUERY_RFC1738。PHP_QUERY_RFC1738将根据REC3986编码和application/x-www-form-urlencoded 媒体类型进行编码,空格会被编码成加号(+)。PHP_QUERY_RFC3986将根据RFC3986编码,空格会被百分号编码(%20)。
    $user = new User("张三", 20);$data = $user;$str = http_build_query($data, 'user', "&", PHP_QUERY_RFC1738);var_dump($str);$str = http_build_query($data, 'user', "|", PHP_QUERY_RFC3986);var_dump($str);

 测试结果

string(30) "name=%E5%BC%A0%E4%B8%89&age=20"
string(30) "name=%E5%BC%A0%E4%B8%89|age=20"

九 array_replace_recursive(array $array, array ...$replacements)

使用传递的数组递归替换第一个数组的元素。后面的数组替换第一个数组,若不存在则在一个数组中创建,若参数中有多于一维的数组会递归遍历。

     $arr1 = [1, 2, "qwe", 4, "asd", ['a', 'b', 'c']];$arr2 = [1, 2, "qwe1", 5, "asd", ['a1', 'b', 'c'], 8];$arr3 = [1, 2, 3, 5, 6, 7];$str = array_replace_recursive($arr1, $arr2, $arr3);var_dump($str);$str = array_replace_recursive($arr1, $arr2);var_dump($str);

测试结果

array(7) {[0]=>   int(1)[1]=>int(2)[2]=>int(3)[3]=>int(5)[4]=>int(6)[5]=>int(7)[6]=>int(8)
}
array(7) {[0]=>int(1)[1]=>int(2)[2]=>string(4) "qwe1"[3]=>int(5)[4]=>string(3) "asd"[5]=>array(3) {[0]=>string(2) "a1"[1]=>string(1) "b"[2]=>string(1) "c"}[6]=>int(8)
}

十 array_unique(array $array, int $flags = SORT_STRING)

移除数组中重复的值。

$flags 用于比较行为,可用值如下:

  1. SORT_REGULAR 按照通常方法比较,不改变数据类型
  2. SORT_NUMERIC 按照数字形式比较,仅比较值
  3. SORT_STRING 按照字符串形式比较 默认,仅比较值
  4. SORT_LOCALE_STRING 根据当前的本地化设置,按照字符串比较
    $arr = ["green", "green1", "green3", "1green", "9a", "2blue", "red"];foreach ($arr as $key => $value) {echo $value . "=>" . (int) $value . PHP_EOL;}$result = array_unique($arr, SORT_NUMERIC);var_dump($result);

测试结果

green=>0
green1=>0
green3=>0
1green=>1
9a=>9
2blue=>2
red=>0
array(4) {[0]=>string(5) "green"[3]=>string(6) "1green"[4]=>string(2) "9a"[5]=>string(5) "2blue"
}

SORT_NUMERIC将值全部转为数字,所以green、green1、green3、red都是0,且仅使用第一个green,所以测试结果中green1、green3、red都未显示。

http://www.yayakq.cn/news/895732/

相关文章:

  • 长沙网站设计公司创建目录wordpress
  • 网站建设信息稿机械类 网站源码
  • 合肥网站的优化新产品的推广销售方法
  • 哪里免费做网站网站建设完毕后怎么加后台
  • 如何自己做解析网站网站建设方案书0
  • 聊城城乡建设局网站怎么在自己做网站
  • 中文域名可以做网站吗微餐饮网站建设平台
  • 门户网站地方生活门户有哪些seo关键词推广价格
  • c 网站开发流程图公司网站能自己做么
  • 网站网络营销方式北京新机场建设指挥部网站
  • 做品牌特价的网站有哪些建设银行交易明细查询网站
  • 英国房产网站大全曲靖网站开发公司
  • 哪几个网站适合自己做外贸小程序开发价格及清单
  • 网站百度推广方案wordpress 自建主题
  • 酷炫html5网站wordpress把站
  • 建筑公司网站的目标用户wordpress下载按钮
  • 中山市网站开发外包公司wordpress 国人 原创 主体
  • 二级网站建设检查评比方案视频内容seo
  • 深圳专业高端网站建设费用网站建设的步骤是什么
  • 网站建设功能的策划书wordpress免费的音乐插件
  • 网站读取速度慢设计公司的网站建设
  • 做企业网站需要准备什么自己怎么做dj 视频网站
  • 北京企业网站定制0元开网店
  • 51网站空间相册在哪里国外有没有做物理小实验的网站
  • 网站怎么架设有些网站为什么可以做资讯
  • a5网站诊断免费的简历模板
  • 做企业销售分析的网站九亭做网站
  • wordpress优秀网站做网站默认城市
  • 煤矿网站建设小游戏网站开发需要什么技术
  • jsp写的网站wordpress邮件系统