1

我正在运行这段代码:

var_dump($this->string);
$this->string = htmlentities($this->string, ENT_COMPAT, "UTF-8", false);
var_dump($this->string);

它在第一个输出字符串var_dump(),但在第二个是空的var_dump()。为什么要这样做?

string(1787) "##Welcome newcomer

We have a `great place` here for you to write whatever you wish, and share it with your friends, family and other random people. Hopefully you enjoy writing for us, we can't wait to see what you have to write about and share with the community! 

##Markdown

We don't use your average editor, we use a much simpler one to write fast HTML code. It is called **Markdown**. Here we will show some basic and common Markdown syntax.

|||OTABLE|||
|||OTR|||
|||OTH|||Example|||CTH|||
|||OTH|||Syntax|||CTH|||
|||OTH|||Description|||CTH|||
|||CTR|||
|||OTR|||
|||OTD|||**Bold**|||CTD|||
|||OTD||||||AST||||||AST|||Bold|||AST||||||AST|||  
|||UND||||||UND|||Bold|||UND||||||UND||||||CTD|||
|||OTD|||Makes text thicker.|||CTD|||
|||CTR|||
|||OTR|||
|||OTD|||_Italic_|||CTD|||
|||OTD||||||AST|||Italic|||AST|||  
|||UND|||Italic|||UND||||||CTD|||
|||OTD|||Makes text slanted|||CTD|||
|||CTR|||
|||OTR|||
|||OTD|||[Google](http://google.com)|||CTD|||
|||OTD||||||LBR|||Google|||RBR||||||LPR|||http://google.com) |||CTD|||
|||OTD|||Makes a text link to a webpage|||CTD|||
|||CTR|||
|||OTR|||
|||OTD|||
|||OBLQU|||I am  
part of  
a quote  
|||CBLQU||||||CTD|||
|||OTD|||
|||GTR|||I am  
|||GTR|||part of  
|||GTR|||a quote  
|||CTD|||
|||OTD|||Creates a quote area|||CTD|||
|||CTR|||
|||OTR|||
|||OTD|||
    <html>
        <head>
            <title>I Am The Title</title>
        </head>
    </html>
|||CTD|||
|||OTD|||
    <html>|||BR|||
        <head>|||BR|||
            <title>I Am The Title</title>|||BR|||
        </head>|||BR|||
    </html>
|||CTD|||
|||OTD|||Creates a block of code|||CTD|||
|||CTR|||
|||OTR|||
|||OTD|||I am `inline code`|||CTD|||
|||OTD|||I am |||TIK|||inline code|||TIK||||||CTD|||
|||OTD|||Creates an inline code block|||CTD|||
|||CTR|||
|||CTABLE|||"
string(0) ""
4

2 回答 2

0

尝试在第三个参数中更改"UTF-8"为。这是PHP 5.4 中引入的"iso-8859-1"一个众所周知的特性。我想它可以完成这项工作。

该死的 PHP 及其开发人员。

于 2014-02-04T04:08:22.053 回答
-2
htmlentities(string, quotestyle, character-set)

只有三个参数

于 2013-10-15T01:55:54.427 回答