• 005——php字符串中的处理函数(四)


    <?php
    /**
     * 字符串处理函数:
     * parse_url  解析URL。返回其组成部分
     */
    /*
    $url="http://www.lantianwang.com/admin/index.php?name=chen&a=add";
    $arr=parse_url($url);
    print_r($arr);//输出:Array ( [scheme] => http [host] => www.lantianwang.com [path] => /admin/index.php [query] => name=chen&a=add )
    echo "<br/>".parse_url($url,PHP_URL_SCHEME);//输出:http
    echo "<br/>".parse_url($url,PHP_URL_HOST);//输出:www.lantianwang.com
    echo "<br/>".parse_url($url,PHP_URL_PATH);//输出:/admin/index.php
    echo "<br/>".parse_url($url,PHP_URL_QUERY);//输出:name=chen&a=add
    */
    
    /*urlencode() url编码:
     *urldecode()  解码,已编码的内容
     * */
    /*
    $str="视频教程PHP课程&divcss课程";
    echo "<a href='5.php?h=".urlencode($str)."'/>蓝天网";
    echo $_GET['h'];//输出:视频教程PHP课程&divcss课程
    */
    /*
    $str2="蓝天网视频教程";
    echo urlencode($str2);
    echo "<br/>";
    echo urldecode(urlencode($str2));
    */
    
    /*htmlentities()讲字符串转化为HTML实体。1.参数:操作内容,
    2:转换规则: ENT_COMPAT(转换双引号)
    ENT_QUOTES(转换单双引号)  ENT_NOQUOTES(不转换任何引号)
     *
     * */
    /*
    $str4='<h1>bbs.lantianwang.com</h1>';
    echo $str4;
    echo htmlentities($str4);
    
    $str4='<h1>bbs.lantianwang.com</h1>"PHP DIV"';
    echo htmlentities($str4);//转换的字符里面双引号也被转换
    */
    /*
    htmlspecialchars(); //不转换中文;
    */
    /*
    $str4='<h1>bbs.lantianwang.com</h1>"中国"';
    echo htmlspecialchars($str4);//输出:<h1>bbs.lantianwang.com</h1>"中国"
    */
    
    echo $_GET['uname'];
    ?>
    <form action="" method="get">
        输入姓名:<input type="text" name="uname">
        <input type="submit" value="提交">
    </form>
    

      

  • 相关阅读:
    Python使用阿里云镜像
    Charles抓取https请求中文乱码的处理方法
    Charles 注册码
    BAT随笔记录(1)
    NodeJS使用puppeteer进行截图
    Centos中文语言乱码解决方法
    CentOS下安装Chrome浏览器中文显示为方框
    CentOS下安装Chrome浏览器
    Jenkines邮件中添加图片
    将HTML转IMAGE
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/7791457.html
Copyright © 2020-2023  润新知