URL 函数 业 ,精于勤 荒于嬉.
- URL 函数 base64_decode 对使用 MIME base64 编码的数据进行解码
-
发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
$str
=
'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='
;
3
echo
base64_decode
(
$str
);
4
?>
- URL 函数 base64_encode 使用 MIME base64 对数据进行编码
-
发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
$str
=
'This is an encoded string'
;
3
echo
base64_encode
(
$str
);
4
?>
- URL 函数 get_headers 取得服务器响应一个 HTTP 请求所发送的所有标头
-
发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
$url
=
'http://www.example.com'
;
3
print_r(get_headers(
$url
));
4
print_r(get_headers(
$url
, 1));
5
?>
示例2
1
<?php
2
// By default get_headers uses a GET request to fetch the headers. If you// want to send a HEAD request instead, you can do so using a stream context:stream_context_set_default( array( 'http' => array( 'method' => 'HEAD' ) ));
3
$headers
= get_headers(
'http://example.com'
);
4
?>
- URL 函数 get_meta_tags 从一个文件中提取所有的 meta 标签 content 属性,返回一个数组
-
发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数
-
示例1
<meta name="author" content="name"> <meta name="keywords" content="php documentation"> <meta name="DESCRIPTION" content="a php manual"> <meta name="geo.position" content="49.33;-86.59"> </head> <!-- 解析工作在此处停止 -->
示例2
1
<?php
2
// 假设上边的标签是在 www.example.com 中$tags = get_meta_tags('http://www.example.com/');
3
// 注意所有的键(key)均为小写,而键中的‘.’则转换成了‘_’。echo $tags['author'];
4
// nameecho $tags['keywords'];
5
// php documentationecho $tags['description'];
6
// a php manualecho $tags['geo_position'];
7
// 49.33;
8
-86.59?>
- URL 函数 http_build_query 生成 URL-encode 之后的请求字符串
-
发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
$data
=
array
(
'foo'
=>
'bar'
,
'baz'
=>
'boom'
,
'cow'
=>
'milk'
,
'php'
=>
'hypertext processor'
);
3
echo
http_build_query(
$data
) .
"\n"
;
4
echo
http_build_query(
$data
,
''
, '&
5
');
6
?>
示例2
1
<?php
2
$data
=
array
(
'foo'
,
'bar'
,
'baz'
,
'boom'
,
'cow'
=>
'milk'
,
'php'
=>
'hypertext processor'
);
3
echo
http_build_query(
$data
) .
"\n"
;
4
echo
http_build_query(
$data
,
'myvar_'
);
5
?>
示例3
1
<?php
2
$data
=
array
(
'user'
=>
array
(
'name'
=>
'Bob Smith'
,
'age'
=>47,
'sex'
=>
'M'
,
'dob'
=>
'5/12/1956'
),
'pastimes'
=>
array
(
'golf'
,
'opera'
,
'poker'
,
'rap'
),
'children'
=>
array
(
'bobby'
=>
array
(
'age'
=>12,
'sex'
=>
'M'
),
'sally'
=>
array
(
'age'
=>8,
'sex'
=>
'F'
)),
'CEO'
);
3
echo
http_build_query(
$data
,
'flags_'
);
4
?>
示例4
01
<?php
02
class
parentClass {
03
public
$pub
=
'publicParent'
;
04
protected
$prot
=
'protectedParent'
;
05
private
$priv
=
'privateParent'
;
06
public
$pub_bar
= Null;
07
protected
$prot_bar
= Null;
08
private
$priv_bar
= Null;
09
public
function
__construct(){
10
$this
->pub_bar =
new
childClass();
11
$this
->prot_bar =
new
childClass();
12
$this
->priv_bar =
new
childClass();
13
}
14
}
15
class
childClass {
16
public
$pub
=
'publicChild'
;
17
protected
$prot
=
'protectedChild'
;
18
private
$priv
=
'privateChild'
;
19
}
20
$parent
=
new
parentClass();
21
echo
http_build_query(
$parent
);
22
?>
- URL 函数 parse_url 解析 URL,返回其组成部分
-
发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
$url
=
'http://username:password@hostname/path?arg=value#anchor'
;
3
print_r(
parse_url
(
$url
));
4
echo
parse_url
(
$url
, PHP_URL_PATH);
5
?>
示例2
1
<?php
2
$url
=
'//www.example.com/path?googleguy=googley'
;
3
// 在 5.4.7 之前这会输出路径 "//www.example.com/path"var_dump(parse_url($url));
4
?>
- URL 函数 rawurldecode 对已编码的 URL 字符串进行解码
-
发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
echo
rawurldecode(
'foo%20bar%40baz'
);
3
// foo bar@baz?>
- URL 函数 rawurlencode 按照 RFC 3986 对 URL 进行编码
-
发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数
-
示例1
示例2
1
<?php
2
echo
'<a href="http://example.com/department_list_script/'
, rawurlencode(
'sales and marketing/Miami'
),
'">'
;
3
?>
- URL 函数 urldecode 解码已编码的 URL 字符串
-
发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
$query
=
"my=apples&are=green+and+red"
;
3
foreach
(
explode
(
'&'
,
$query
)
as
$chunk
) {
4
$param
=
explode
(
"="
,
$chunk
);
5
if
(
$param
) {
6
printf(
"Value for parameter \"%s\" is \"%s\"\n"
, urldecode(
$param
[0]), urldecode(
$param
[1]));
7
}
8
}
9
?>
- URL 函数 urlencode 编码 URL 字符串
-
发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数
-
示例1
1
<?php
2
echo
'<a href="mycgi?foo='
, urlencode(
$userinput
),
'">'
;
3
?>
示例2
1
<?php
2
$query_string
=
'foo='
. urlencode(
$foo
) .
'&bar='
. urlencode(
$bar
);
3
echo
'<a href="mycgi?'
. htmlentities(
$query_string
) .
'">'
;
4
?>
- 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)