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]] )
  • 相关阅读:
    go学习中的零散笔记
    git reset --hard与git reset --soft的区别
    php必学必会
    gdb 解core
    php学习
    高仿京东到家APP引导页炫酷动画效果
    RxHttp
    SVN回滚文件
    遍历枚举
    python3 多线程
  • 原文地址:https://www.cnblogs.com/liuchen/p/364184.html
Copyright © 2011-2022 走看看