首页 > 解决方案 > 在 json_encode($json, JSON_UNESCAPED_SLASHES) 中转义 css 类的方法

问题描述

我有一个 php 文件,它填充变量并将它们集成到一个 html 表中。为此,我将 json_encode 与 JSON_UNESCAPED_SLASHES 一起使用,以便我可以动态加载它们并且格式正确。(出于过滤原因)

但我的问题似乎是不再代表 css 类,因为我使用了 JSON_UNESCAPED_SLASHES,所以我不知道如何逃脱。

$json = '<thead>
    <tr>
        <th>Herkunft</th>
        <th>Altersstaffelung</th>
        <th>Punktwert</th>
        <th>Anzahl Mitglieder</th>
        <th>Anzahl Famis</th>
        <th>Versicherte Gesamt</th>
        <th>Punkte</th>
        <th>Anzahl Mitglieder</th>
        <th>Anzahl Famis</th>
        <th>Versicherte Gesamt</th>
        <th>Punkte</th>
        <th>Summe</th>
    </tr>
</thead>
    <tbody>
    <tr class="gkv">
<td rowspan="2"><p>GKV/PKV</p> (mit oder ohne Vertriebspartnerbeteiligung)</td>
<td>bis 30 Jahre</td>
<td>5</td>
<td>    '.$Mitglied_GKV_PKV_j.'</td>
            <td>'.$Fami_GKV_PKV_j.'</td>
            <td>'.$Versicherte_GKV_PKV_j.'</td>
            <td>'.$Punkte_GKV_PKV_j.'</td>
            <td>'.$Mitglied_GKV_PKV_j_vp.'</td>
            <td>'.$Fami_GKV_PKV_j_vp.'</td>
            <td>'.$Versicherte_GKV_PKV_j_vp.'</td>
            <td>'.$Punkte_GKV_PKV_j_vp.'</td>
            <td>'.$Summe_GKV_PKV_j_vp.'</td>
        </tr>
</tbody>';
echo json_encode($json, JSON_UNESCAPED_SLASHES);

除了 rowspan 和 css 类之外,一切都很好。

标签: phphtmlcss

解决方案


推荐阅读