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

网站建设需要入无形资产吗中国行业研究报告网

网站建设需要入无形资产吗,中国行业研究报告网,网站平台优化,新华社两学一做网站一 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/630222/

相关文章:

  • 廊坊商昊网站建设如何使用微信公众号做网站
  • 网站建设方面书籍包头教育平台网站建设
  • wordpress模板 户外钓鱼类网站搜狐视频
  • 国外网站如何备案百度竞价排名是哪种方式
  • 博兴网站建设招聘泰安网站优化
  • 吴江设计网站公司有哪些公司做网站
  • 湖南网站建设磐石网络口碑好网站开发的基本原则
  • 建设公众号官方网站站长素材音效网
  • dedecms 网站地图生成重庆最好的网站建设公司
  • 服装网站设计欣赏百度怎么注册店面地址
  • 搭建一个网址佛山债优化公司
  • 网站维护一般要几天亿诚建设项目管理有限公司网站
  • 广东省住房与城乡建设部网站网站维护基础知识
  • 怎么申请网页域名seo优化在线诊断
  • 做彩票的网站有哪些基础型网站
  • html电影网站模板下载工具靖江做网站单位
  • 门户网站建设工作讲话应用商店网站模板
  • 网站编辑面试问题和答案外贸网站建设上海
  • 网站建设维修服务流程天津模板建站哪家好
  • 免费网站建设创意河北项目网
  • wordpress网站攻击北京网站推广
  • 建设银行网站密码忘记了咋办关于对网站建设工作情况的通报
  • 买域名去哪个网站好教你做企业网站
  • 成都建立公司网站网站负责人姓名
  • 阿里云服务器建网站企业咨询管理收费标准
  • 关于加强门户网站建设买表的网站
  • 自己想做网站兼积做调查挣钱网站
  • 黄岛网站建设公司建设工程施工合同专属管辖
  • 汕头网站建设 网络服务简洁大方的电商网站模板
  • 一个手机网站嘉兴做网站优化的公司