<dl id="sseui"><tr id="sseui"></tr></dl><code id="sseui"><delect id="sseui"></delect></code>
<noframes id="sseui"><fieldset id="sseui"></fieldset></noframes>
  • \nBill & 'Steve'
    \nBill & 'Tarzan'
    \nBill & 'Steve'\n<\/body> \n<\/html> \n<\/pre>\n\n

    Browser output of the above code: <\/p>\n\n

    \nBill & 'Steve'\nBill & 'Steve'\nBill & 'Steve' \n<\/pre>\n\n

    Example 2<\/strong><\/p>\n

    Convert some characters to HTML entities by using the Western European character set: <\/p>\n\n

    \n<?php \n$str = \"My name is ?yvind ?sane. I'm Norwegian.\"; \necho htmlentities($str, ENT_QUOTES, \"ISO-8859-1\"); \n\/\/ Will only convert double quotes (not single quotes), and uses the character-set Western European \n?> \n<\/pre>\n\n

    The HTML output of the above code is as follows (view source code): <\/p>\n\n

    \n \n \n
    

    国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

    \nMy name is Øyvind Åsane. I'm Norwegian. \n<\/body> \n<\/html> \n<\/pre>\n\n

    Browser output of the above code: <\/p>\n

    My name is ?yvind ?sane. I'm Norwegian.
    \n<\/p>\n

    The above definition and usage of the php htmlentities() function is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia. <\/p>\n

    <\/p>\n

    \nhttp:\/\/www.bkjia.com\/PHPjc\/1127919.html<\/span>www.bkjia.com<\/span>true<\/span>http: \/\/www.bkjia.com\/PHPjc\/1127919.html<\/span>TechArticle<\/span>Definition and usage of php htmlentities() function, phphtmlentities php htmlentities() function converts characters into HTML entities, this The article introduces the basic usage of php htmlentities() function to programmers...<\/span>\n<\/div>\n
    <\/div>"}
    Table of Contents
    Definition and usage of php htmlentities() function, phphtmlentities
    Home Backend Development PHP Tutorial Definition and usage of php htmlentities() function, phphtmlentities_PHP tutorial

    Definition and usage of php htmlentities() function, phphtmlentities_PHP tutorial

    Jul 12, 2016 am 08:51 AM
    htmlentities php function

    Definition and usage of php htmlentities() function, phphtmlentities

    php htmlentities() function converts characters into HTML entities. This article introduces the basics of php htmlentities() function to coders The usage method and examples are introduced. Coders in need can refer to it.

    Definition and usage

    The

    htmlentities() function converts characters into HTML entities.

    Tip: To convert HTML entities back to characters, use the html_entity_decode() function.

    Tip: Please use the get_html_translation_table() function to return the translation table used by htmlentities().

    Grammar

    htmlentities(string,flags,character-set,double_encode)

    Parameters Description
    string Required. Specifies the string to be converted.
    flags
    參數 描述
    string 必需。規(guī)定要轉換的字符串。
    flags

    可選。規(guī)定如何處理引號、無效的編碼以及使用哪種文檔類型。

    可用的引號類型:

    • ENT_COMPAT - 默認。僅編碼雙引號。
    • ENT_QUOTES - 編碼雙引號和單引號。
    • ENT_NOQUOTES - 不編碼任何引號。

    無效的編碼:

    • ENT_IGNORE - 忽略無效的編碼,而不是讓函數返回一個空的字符串。應盡量避免,因為這可能對安全性有影響。
    • ENT_SUBSTITUTE - 把無效的編碼替代成一個指定的帶有 Unicode 替代字符 U FFFD(UTF-8)或者 FFFD; 的字符,而不是返回一個空的字符串。
    • ENT_DISALLOWED - 把指定文檔類型中的無效代碼點替代成 Unicode 替代字符 U FFFD(UTF-8)或者 FFFD;。

    規(guī)定使用的文檔類型的附加 flags:

    • ENT_HTML401 - 默認。作為 HTML 4.01 處理代碼。
    • ENT_HTML5 - 作為 HTML 5 處理代碼。
    • ENT_XML1 - 作為 XML 1 處理代碼。
    • ENT_XHTML - 作為 XHTML 處理代碼。
    character-set

    可選。一個規(guī)定了要使用的字符集的字符串。

    允許的值:

    • UTF-8 - 默認。ASCII 兼容多字節(jié)的 8 位 Unicode
    • ISO-8859-1 - 西歐
    • ISO-8859-15 - 西歐(加入歐元符號 ISO-8859-1 中丟失的法語和芬蘭語字母)
    • cp866 - DOS 專用 Cyrillic 字符集
    • cp1251 - Windows 專用 Cyrillic 字符集
    • cp1252 - Windows 專用西歐字符集
    • KOI8-R - 俄語
    • BIG5 - 繁體中文,主要在臺灣使用
    • GB2312 - 簡體中文,國家標準字符集
    • BIG5-HKSCS - 帶香港擴展的 Big5
    • Shift_JIS - 日語
    • EUC-JP - 日語
    • MacRoman - Mac 操作系統(tǒng)使用的字符集

    注釋:在 PHP 5.4 之前的版本,無法被識別的字符集將被忽略并由 ISO-8859-1 替代。自 PHP 5.4 起,無法被識別的字符集將被忽略并由 UTF-8 替代。

    double_encode

    可選。布爾值,規(guī)定是否編碼已存在的 HTML 實體。

    • TRUE - 默認。將對每個實體進行轉換。
    • FALSE - 不會對已存在的 HTML 實體進行編碼。
    Optional. Specifies how to handle quotes, invalid encodings, and which document type to use.

    Available quote types:

    • ENT_COMPAT - Default. Only double quotes are encoded.
    • ENT_QUOTES - Encodes double and single quotes.
    • ENT_NOQUOTES - Do not encode any quotes.

    Invalid encoding:

    返回值:

    返回被轉換的字符串。

    如果?string?包含無效的編碼,則返回一個空的字符串,除非設置了 ENT_IGNORE 或者 ENT_SUBSTITUTE 標志。

    PHP 版本: 4
    更新日志:

    在 PHP 5 中,character-set?參數的默認值改為 UTF-8。

    在 PHP 5.4 中,新增了:ENT_SUBSTITUTE、ENT_DISALLOWED、ENT_HTML401、ENT_HTML5、ENT_XML1 和 ENT_XHTML。

    在 PHP 5.3 中,新增了 ENT_IGNORE。

    在 PHP 5.2.3 中,新增了?double_encode?參數。

    在 PHP 4.1 中,新增了?character-set?參數。

    • ENT_IGNORE - Ignore invalid encodings instead of having the function return an empty string. This should be avoided as this may have an impact on security.
    • ENT_SUBSTITUTE - Substitutes an invalid encoding with the specified character with the Unicode replacement character U FFFD (UTF-8) or FFFD; instead of returning an empty string.
    • ENT_DISALLOWED - Replaces invalid code points in the specified document type with the Unicode replacement character U FFFD (UTF-8) or FFFD;.
    Additional flags specifying the document type to use:
    • ENT_HTML401 - Default. Code processed as HTML 4.01.
    • ENT_HTML5 - Process code as HTML 5.
    • ENT_XML1 - code processed as XML 1.
    • ENT_XHTML - as XHTML processing code.
    character-set Optional. A string specifying the character set to be used. Allowed values:
    • UTF-8 - Default. ASCII compatible multi-byte 8-bit Unicode
    • ISO-8859-1 - Western Europe
    • ISO-8859-15 - Western Europe (adds French and Finnish letters missing from ISO-8859-1 for Euro symbol)
    • cp866 - DOS-specific Cyrillic character set
    • cp1251 - Cyrillic character set for Windows
    • cp1252 - Windows-specific Western European character set
    • KOI8-R - Russian
    • BIG5 - Traditional Chinese, mainly used in Taiwan
    • GB2312 - Simplified Chinese, national standard character set
    • BIG5-HKSCS - Big5 with Hong Kong extension
    • Shift_JIS - Japanese
    • EUC-JP - Japanese
    • MacRoman - Character set used by Mac operating systems
    Note: In versions prior to PHP 5.4, unrecognized character sets will be ignored and replaced by ISO-8859-1. As of PHP 5.4, unrecognized character sets are ignored and replaced by UTF-8.
    double_encode Optional. Boolean value that specifies whether to encode existing HTML entities.
    • TRUE - Default. Each entity will be converted.
    • FALSE - Existing HTML entities will not be encoded.
    Technical details
    Return value: Returns the converted string. If string contains an invalid encoding, an empty string is returned unless the ENT_IGNORE or ENT_SUBSTITUTE flag is set.
    PHP version: 4
    Update log: In PHP 5, the default value of the character-set parameter is changed to UTF-8. In PHP 5.4, new: ENT_SUBSTITUTE, ENT_DISALLOWED, ENT_HTML401, ENT_HTML5, ENT_XML1 and ENT_XHTML. In PHP 5.3, ENT_IGNORE was added. In PHP 5.2.3, the double_encode parameter is added. In PHP 4.1, there is a new character-set parameter.

    Example 1

    Convert characters to HTML entities:

    <&#63;php 
    $str = "Bill & 'Steve'"; 
    echo htmlentities($str, ENT_COMPAT); // 只轉換雙引號 
    echo "<br>"; 
    echo htmlentities($str, ENT_QUOTES); // 轉換雙引號和單引號 
    echo "<br>"; 
    echo htmlentities($str, ENT_NOQUOTES); // 不轉換任何引號 
    &#63;> 
    

    The HTML output of the above code is as follows (view source code):

    <!DOCTYPE html> 
    <html> 
    <body> 
    Bill & 'Steve'<br> 
    Bill & 'Tarzan'<br> 
    Bill & 'Steve'
    </body> 
    </html> 
    

    Browser output of the above code:

    Bill & 'Steve'
    Bill & 'Steve'
    Bill & 'Steve' 
    

    Example 2

    Convert some characters to HTML entities by using the Western European character set:

    <&#63;php 
    $str = "My name is &#63;yvind &#63;sane. I'm Norwegian."; 
    echo htmlentities($str, ENT_QUOTES, "ISO-8859-1"); 
    // Will only convert double quotes (not single quotes), and uses the character-set Western European 
    &#63;> 
    

    The HTML output of the above code is as follows (view source code):

    <!DOCTYPE html> 
    <html> 
    <body> 
    My name is &Oslash;yvind &Aring;sane. I'm Norwegian. 
    </body> 
    </html> 
    

    Browser output of the above code:

    My name is ?yvind ?sane. I'm Norwegian.

    The above definition and usage of the php htmlentities() function is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia.

    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127919.htmlTechArticleDefinition and usage of php htmlentities() function, phphtmlentities php htmlentities() function converts characters into HTML entities, this The article introduces the basic usage of php htmlentities() function to programmers...
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Using std::chrono in C Using std::chrono in C Jul 15, 2025 am 01:30 AM

    std::chrono is used in C to process time, including obtaining the current time, measuring execution time, operation time point and duration, and formatting analysis time. 1. Use std::chrono::system_clock::now() to obtain the current time, which can be converted into a readable string, but the system clock may not be monotonous; 2. Use std::chrono::steady_clock to measure the execution time to ensure monotony, and convert it into milliseconds, seconds and other units through duration_cast; 3. Time point (time_point) and duration (duration) can be interoperable, but attention should be paid to unit compatibility and clock epoch (epoch)

    How does PHP handle Environment Variables? How does PHP handle Environment Variables? Jul 14, 2025 am 03:01 AM

    ToaccessenvironmentvariablesinPHP,usegetenv()orthe$_ENVsuperglobal.1.getenv('VAR_NAME')retrievesaspecificvariable.2.$_ENV['VAR_NAME']accessesvariablesifvariables_orderinphp.iniincludes"E".SetvariablesviaCLIwithVAR=valuephpscript.php,inApach

    Why We Comment: A PHP Guide Why We Comment: A PHP Guide Jul 15, 2025 am 02:48 AM

    PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

    PHP prepared statement get result PHP prepared statement get result Jul 14, 2025 am 02:12 AM

    The method of using preprocessing statements to obtain database query results in PHP varies from extension. 1. When using mysqli, you can obtain the associative array through get_result() and fetch_assoc(), which is suitable for modern environments; 2. You can also use bind_result() to bind variables, which is suitable for situations where there are few fields and fixed structures, and it is good compatibility but there are many fields when there are many fields; 3. When using PDO, you can obtain the associative array through fetch (PDO::FETCH_ASSOC), or use fetchAll() to obtain all data at once, so the interface is unified and the error handling is clearer; in addition, you need to pay attention to parameter type matching, execution of execute(), timely release of resources and enable error reports.

    PHP check if a string starts with a specific string PHP check if a string starts with a specific string Jul 14, 2025 am 02:44 AM

    In PHP, you can use a variety of methods to determine whether a string starts with a specific string: 1. Use strncmp() to compare the first n characters. If 0 is returned, the beginning matches and is not case sensitive; 2. Use strpos() to check whether the substring position is 0, which is case sensitive. Stripos() can be used instead to achieve case insensitive; 3. You can encapsulate the startsWith() or str_starts_with() function to improve reusability; in addition, it is necessary to note that empty strings return true by default, encoding compatibility and performance differences, strncmp() is usually more efficient.

    how to avoid undefined index error in PHP how to avoid undefined index error in PHP Jul 14, 2025 am 02:51 AM

    There are three key ways to avoid the "undefinedindex" error: First, use isset() to check whether the array key exists and ensure that the value is not null, which is suitable for most common scenarios; second, use array_key_exists() to only determine whether the key exists, which is suitable for situations where the key does not exist and the value is null; finally, use the empty merge operator?? (PHP7) to concisely set the default value, which is recommended for modern PHP projects, and pay attention to the spelling of form field names, use extract() carefully, and check the array is not empty before traversing to further avoid risks.

    PHP prepared statement with IN clause PHP prepared statement with IN clause Jul 14, 2025 am 02:56 AM

    When using PHP preprocessing statements to execute queries with IN clauses, 1. Dynamically generate placeholders according to the length of the array; 2. When using PDO, you can directly pass in the array, and use array_values to ensure continuous indexes; 3. When using mysqli, you need to construct type strings and bind parameters, pay attention to the way of expanding the array and version compatibility; 4. Avoid splicing SQL, processing empty arrays, and ensuring data types match. The specific method is: first use implode and array_fill to generate placeholders, and then bind parameters according to the extended characteristics to safely execute IN queries.

    How to Install PHP on Windows How to Install PHP on Windows Jul 15, 2025 am 02:46 AM

    The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

    See all articles