zoukankan      html  css  js  c++  java
  • htmlspecialchars()函数

    htmlspecialchars()函数,把 < 和 > 转换为实体,常用于防止浏览器将其用作 HTML 元素。

     1  <!DOCTYPE html>
     2 <html>
     3 <body>
     4 
     5 <?php
     6 $str = "This is some <b>bold</b> text.";
     7 echo htmlspecialchars($str);
     8 ?>
     9 
    10 <p><> 转换为实体常用于防止浏览器将其用作 HTML 元素。当用户有权在您的页面上显示输入时,对于防止代码运行非常有用。</p>
    11 
    12 </body>
    13 </html>

    结果:

    This is some <b>bold</b> text.
    
    把 <> 转换为实体常用于防止浏览器将其用作 HTML 元素。当用户有权在您的页面上显示输入时,对于防止代码运行非常有用。
  • 相关阅读:
    百斯特
    C++
    转载
    转载+整理
    转载
    转载
    转载
    C++
    转载
    CodeForces
  • 原文地址:https://www.cnblogs.com/wanlibingfeng/p/7263137.html
Copyright © 2011-2022 走看看