Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.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 将html内容转换为普通html_Php_Html_Xml_Xhtml - Fatal编程技术网

Php 将html内容转换为普通html

Php 将html内容转换为普通html,php,html,xml,xhtml,Php,Html,Xml,Xhtml,我正在用PHP编写一个导入函数,用于从发布者导入新闻。他们的API给了我newsml1.2格式的响应,一切都很好,但是新闻的主体看起来是这样的 %26lt%3Bp%26gt%3B4+ya%C5%9F%C4%B1ndalar%2C+1+milyon+liradan+fazla+bor%C3%A7lar%C4%B1+var%26lt%3B%2Fp%26gt%3B%26lt%3Bp%26gt%3B- 我不知道格式是什么,我尝试过这些功能,但没有任何改变: $body = my

我正在用PHP编写一个导入函数,用于从发布者导入新闻。他们的API给了我newsml1.2格式的响应,一切都很好,但是新闻的主体看起来是这样的

%26lt%3Bp%26gt%3B4+ya%C5%9F%C4%B1ndalar%2C+1+milyon+liradan+fazla+bor%C3%A7lar%C4%B1+var%26lt%3B%2Fp%26gt%3B%26lt%3Bp%26gt%3B-
我不知道格式是什么,我尝试过这些功能,但没有任何改变:

            $body = mysql_real_escape_string($body);
            iconv(mb_detect_encoding($body, mb_detect_order(), true), "UTF-8", $body);
            htmlspecialchars($body, ENT_NOQUOTES, "UTF-8");
            $body = nl2br(html_entity_decode($body));
谁能告诉我该怎么办。谢谢

p、 美国

我使用curl获取新闻列表:

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_ENCODING, "UTF-8");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERPWD, $HAS_USERNAME . ":" . $HAS_PASSWORD);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        $response = curl_exec($ch);
而不是simplexml

$xml = @simplexml_load_string($response);
对响应使用
urldecode()

header('Content-Type: text/html; charset=utf-8');
$response = '%26lt%3Bp%26gt%3B4+ya%C5%9F%C4%B1ndalar%2C+1+milyon+liradan+fazla+bor%C3%A7lar%C4%B1+var%26lt%3B%2Fp%26gt%3B%26lt%3Bp%26gt%3B-';
$response = urldecode($response);
echo $response; // <p>4 yaşındalar, 1 milyon liradan fazla borçları var</p><p>-
header('Content-Type:text/html;charset=utf-8');
$response='%26lt%3Bp%26gt%3B4+ya%C5%9F%C4%B1ndalar%2C+1+milyon+liradan+fazla+bor%C3%A7lar%C4%B1+var%26lt%3B%2Fp%26gt%3B%26lt%3Bp%26gt%3B-';
$response=urldecode($response);
echo$response;// 4亚当达尔,1米利扬·利拉丹·法兹拉·博雷瓦尔

-
对响应使用
urldecode()

header('Content-Type: text/html; charset=utf-8');
$response = '%26lt%3Bp%26gt%3B4+ya%C5%9F%C4%B1ndalar%2C+1+milyon+liradan+fazla+bor%C3%A7lar%C4%B1+var%26lt%3B%2Fp%26gt%3B%26lt%3Bp%26gt%3B-';
$response = urldecode($response);
echo $response; // <p>4 yaşındalar, 1 milyon liradan fazla borçları var</p><p>-
header('Content-Type:text/html;charset=utf-8');
$response='%26lt%3Bp%26gt%3B4+ya%C5%9F%C4%B1ndalar%2C+1+milyon+liradan+fazla+bor%C3%A7lar%C4%B1+var%26lt%3B%2Fp%26gt%3B%26lt%3Bp%26gt%3B-';
$response=urldecode($response);
echo$response;// 4亚当达尔,1米利扬·利拉丹·法兹拉·博雷瓦尔

-
@Xiabili当然很高兴helped@Xiabili当然很高兴它起了作用