Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htmlentities正在使字符串为空_Php_Html Entities - Fatal编程技术网

Php htmlentities正在使字符串为空

Php htmlentities正在使字符串为空,php,html-entities,Php,Html Entities,我正在运行这段代码: 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 pla

我正在运行这段代码:

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) ""
string(1787)”##欢迎新来者
我们这里有一个“很棒的地方”,你可以写任何你想写的东西,并与你的朋友、家人和其他随意的人分享。希望你喜欢为我们写作,我们迫不及待地想看看你要写什么,并与社区分享!
##降价
我们不使用普通的编辑器,我们使用一个简单得多的编辑器来编写快速HTML代码。它被称为**标记**。这里我们将展示一些基本和常用的标记语法。
|||可旋转|||
|||奥特|||
|||其他| | |示例| | | CTH|||
|||其他语法|||
|||其他| | |描述| | | CTH|||
|||中心|||
|||奥特|||
|||OTD | | |**粗体**| | | CTD|||
|||OTD|||||AST|AST|AST|AST|AST|AST|AST|
|||乌德|乌德|乌德|乌德|乌德|乌德|乌德|乌德|乌德|乌德|乌德|乌德|乌德||||
|||OTD | | | |使文本更厚。| | | | CTD|||
|||中心|||
|||奥特|||
|||OTD | | | | | U斜体| | | | CTD|||
|||OTD | | | | | | | | | | | | | | | AST | |
|||UND | | | Italic | | | | UND | | | | | | | | | CTD|||
|||OTD | | |使文本倾斜| | | CTD|||
|||中心|||
|||奥特|||
|||OTD | | |[谷歌](http://google.com)|||CTD|||
|||OTD、LBR、谷歌、RBR、LPR|||http://google.com)| | | CTD|||
|||OTD制作一个指向网页的文本链接|||
|||中心|||
|||奥特|||
|||OTD|||
|||我是
部分
引述
|||CBLQU、CTD|||
|||OTD|||
|||全球技术法规| | |我是
|||全球技术法规| | |的一部分
|||全球技术法规| | |引用
|||CTD|||
|||OTD | | | |创建报价区域| | | CTD|||
|||中心|||
|||奥特|||
|||OTD|||
我是冠军
|||CTD|||
|||OTD|||
|||溴|||
|||溴|||
我是头衔| | | BR|||
|||溴|||
|||CTD|||
|||OTD | | | |创建一个代码块| | | CTD|||
|||中心|||
|||奥特|||
|||OTD | | | | | | |我是`内联代码'| | | | CTD|||
|||OTD | | | | | | | | | | | | | | | | | | | TIK | | CTD|||
|||OTD | | | |创建内联代码块| | | CTD|||
|||中心|||
|||CTABLE | | |”
字符串(0)”
只有三个参数

尝试将第三个参数中的
“UTF-8”
更改为
“iso-8859-1”
。这是一个众所周知的bu。我想它能起作用


该死的PHP及其开发人员。

文档中说“如果输入字符串在给定的编码中包含无效的代码单元序列,将返回一个空字符串”。话虽如此,我还是尝试了你的代码并得到了正确的输出…我不这么认为,因为这很奇怪,我在测试页面上运行它,它工作得很好,但是当我在实际的网页中运行它时,它不起作用…添加
ENT\u IGNORE
可以解决问题,尽管PHP版本是什么?不鼓励使用
ENT\u IGNORE
标志,因为它会导致错误。如果
ENT\U IGNORE
起作用,则证明您的内容包含无效字符。此外,
ENT\U DISALLOWED
标志将在您的案例(UTF-8)中用
U+FFFD
替换无效字符,从而您可以找到无效字符的位置。No。它最多可接受4个字符,请查看。
htmlentities(string, quotestyle, character-set)