URL 函数 业 ,精于勤 荒于嬉.

URL 函数 base64_decode 对使用 MIME base64 编码的数据进行解码

发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数

      示例1
<?php 
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);
?>

阅读全文 »

URL 函数 base64_encode 使用 MIME base64 对数据进行编码

发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数

      示例1
<?php 
$str = 'This is an encoded string';
echo base64_encode($str);
?>

阅读全文 »

URL 函数 get_headers 取得服务器响应一个 HTTP 请求所发送的所有标头

发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数

      示例1
<?php 
$url = 'http://www.example.com';
print_r(get_headers($url));
print_r(get_headers($url, 1));
?>

      示例2
<?php 
// 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'        )    ));
$headers = get_headers('http://example.com');
?>

阅读全文 »

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
<?php 
// 假设上边的标签是在 www.example.com 中$tags = get_meta_tags('http://www.example.com/');
// 注意所有的键(key)均为小写,而键中的‘.’则转换成了‘_’。echo $tags['author'];
       // nameecho $tags['keywords'];
     // php documentationecho $tags['description'];
  // a php manualecho $tags['geo_position'];
 // 49.33;
-86.59?>

阅读全文 »

URL 函数 http_build_query 生成 URL-encode 之后的请求字符串

发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数

      示例1
<?php 
$data = array('foo'=>'bar',              'baz'=>'boom',              'cow'=>'milk',              'php'=>'hypertext processor');
echo http_build_query($data) . "\n";
echo http_build_query($data, '', '&amp;
');
?>

      示例2
<?php 
$data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor');
echo http_build_query($data) . "\n";
echo http_build_query($data, 'myvar_');
?>

      示例3
<?php 
$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');
echo http_build_query($data, 'flags_');
?>

      示例4
<?php 
class parentClass {
    public    $pub      = 'publicParent';
    protected $prot     = 'protectedParent';
    private   $priv     = 'privateParent';
    public    $pub_bar  = Null;
    protected $prot_bar = Null;
    private   $priv_bar = Null;
    public function __construct(){
        $this->pub_bar  = new childClass();
        $this->prot_bar = new childClass();
        $this->priv_bar = new childClass();
    }
}
class childClass {
    public    $pub  = 'publicChild';
    protected $prot = 'protectedChild';
    private   $priv = 'privateChild';
}
$parent = new parentClass();
echo http_build_query($parent);
?>

阅读全文 »

URL 函数 parse_url 解析 URL,返回其组成部分

发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数

      示例1
<?php 
$url = 'http://username:password@hostname/path?arg=value#anchor';
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH);
?>

      示例2
<?php 
$url = '//www.example.com/path?googleguy=googley';
// 在 5.4.7 之前这会输出路径 "//www.example.com/path"var_dump(parse_url($url));
?>

阅读全文 »

URL 函数 rawurldecode 对已编码的 URL 字符串进行解码

发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数

      示例1
<?php 
echo rawurldecode('foo%20bar%40baz');
 // foo bar@baz?>

阅读全文 »

URL 函数 rawurlencode 按照 RFC 3986 对 URL 进行编码

发表日期:2021-07-01 08:56:30 | 来源: | 分类:URL 函数

      示例1
<?php 
echo '<a href="ftp://user:', rawurlencode('foo @+%/'),     '@ftp.example.com/x.txt">';
?>

      示例2
<?php 
echo '<a href="http://example.com/department_list_script/',    rawurlencode('sales and marketing/Miami'), '">';
?>

阅读全文 »

URL 函数 urldecode 解码已编码的 URL 字符串

发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数

      示例1
<?php 
$query = "my=apples&are=green+and+red";
foreach (explode('&', $query) as $chunk) {
    $param = explode("=", $chunk);
    if ($param) {
        printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
    }
}
?>

阅读全文 »

URL 函数 urlencode 编码 URL 字符串

发表日期:2021-07-01 08:56:31 | 来源: | 分类:URL 函数

      示例1
<?php 
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>

      示例2
<?php 
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>

阅读全文 »

全部博文(1580)
集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。