zoukankan      html  css  js  c++  java
  • php与html页面交互的几个函数

    1,字符串的转义操作vs取消转义
        form表里面提交的字符串将一些字符,比如',",\等自动添加\转义成为\',\",\\,可以使用函数
    string stripslashes ( string str )
        与此相反,添加转义\字符,可以使用string addslashes ( string str )

    2,显示html和js代码vs执行代码
        有些用户添加一些js代码,然而我们不希望他们执行,仅仅让他们显示,可以使用函数
    string htmlentities ( string string [, int quote_style [, string charset]] )
    string htmlspecialchars ( string string [, int quote_style [, string charset]] )
        作用如下:

            '&' (ampersand) becomes '&' 
            '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. 
            ''' (single quote) becomes ''' only when ENT_QUOTES is set. 
            '<' (less than) becomes '&lt;' 
            '>' (greater than) becomes '&gt;' 

        如果要执行,可以执行相反的函数,如下
    string html_entity_decode ( string string [, int quote_style [, string charset]] )
  • 相关阅读:
    C++中substr函数的用法
    最小生成树-克鲁斯卡尔模板
    最小生成树-prim算法模板
    1064. 朋友数(20)
    1076. Wifi密码 (15)【模拟】
    二分搜索与二分答案
    HDU 1969 Pie【二分】
    1047. 编程团体赛(20)
    1057. 数零壹(20)
    L2-3. 悄悄关注【STL+结构体排序】
  • 原文地址:https://www.cnblogs.com/liuchen/p/364184.html
Copyright © 2011-2022 走看看