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);
?>
<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>