Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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
XML字符串存储为变量中的字符串,无需PHP解析(JSON中的XML)_Xml_Json - Fatal编程技术网

XML字符串存储为变量中的字符串,无需PHP解析(JSON中的XML)

XML字符串存储为变量中的字符串,无需PHP解析(JSON中的XML),xml,json,Xml,Json,这很简单,但我不明白我错在哪里。代码是: <?php $v='<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>'; print $v; ?> 如果我查看页面源代码,我会得到 <?xml version="1.0" ?><span style="font-size:10px">{point.key}</s

这很简单,但我不明白我错在哪里。代码是:

<?php
$v='<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>';
print $v;
?>
如果我查看页面源代码,我会得到

<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>
而不是

headerFormat:'<span style="font-size:10px">{point.key}</span><table>'
headerFormat:“{point.key}”

一旦打印了
$v
,浏览器就会解释标签。如果不希望像
这样的内容被视为实际的HTML,则必须转义字符串。PHP中最简单的方法是:

这将在浏览器中为您提供所需的内容

<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>
"tooltip": {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}:</td><td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
    },
headerFormat: '{point.key}'`
headerFormat:'<span style="font-size:10px">{point.key}</span><table>'
<?php
$v='<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>';
print htmlspecialchars($v);
?>
&lt;?xml version=&quot;1.0&quot; ?&gt;&lt;span style=&quot;font-size:10px&quot;&gt;{point.key}&lt;/span&gt;&lt;table&gt;