如何实现以下目标,我希望在 switch 语句中回显硬编码数据:
<?php foreach ($xmlObject->fields[0]->field as $field) {
switch((string) $field['name']) {
echo "<td>" . $c . "</td>";
echo "<td>1</td>";
case 'published':
echo "<td>" . $field->value . "</td>";
echo "<td>" . $field->value . "</td>";
break;
case 'body':
echo "<td>" . htmlentities($field->value) . "</td>";
break;
case 'title':
echo "<td>" . $field->value . "</td>";
break;
case 'summary':
echo "<td>" . $field->value . "</td>";
break;
echo "<td>publish</td>";
echo "<td>closed</td>";
echo "<td>closed</td>";
echo "<td> </td>";
case 'title':
echo "<td>" . $field->value . "</td>";
break;
echo "<td> </td>";
echo "<td> </td>";
case 'published':
echo "<td>" . $field->value . "</td>";
echo "<td>" . $field->value . "</td>";
break;
echo "<td> </td>";
echo "<td>0</td>";
echo "<td>http://www.domain.com/clients/ciw/?p=" . $c . "</td>";
echo "<td>0</td>";
echo "<td>policies</td>";
echo "<td> </td>";
echo "<td>0</td>";
//case 'parentId':
// echo "<td>" . $field->value . "</td>";
// break;
//case 'SubjectArea':
// echo "<td>" . $field->value . "</td>";
// break;
}
} ?>
我收到以下错误:
解析错误:语法错误,意外的 T_ECHO,在第 154 行的 /home/teamwork/public_html/clients/ciw/datatest/index.php 中需要 T_CASE 或 T_DEFAULT 或 '}'
将回显更改为大小写时,它会消除错误但不输出任何内容。