我試過使用html br標籤,「\ r \ n」和PHP_EOL,但我的表格數據不會換行。我不明白爲什麼它只是將它附加到一行而不是給出回車。cakephp 2.X換行符不工作
下面是它是如何目前顯示我的數據的圖像:
<table>
<tr>
<th>Article</th>
<th>Action</th>
</tr>
<?php
foreach ($posts as $post):
?>
<tr>
<td>
<?php
echo $this->Html->link($this->Time->format($post['Post']['created'], '%d %b %Y', 'invalid')
. " - " . $post['Post']['article_title']
. PHP_EOL . "<br />\n" . "\r\n"
. $post['Post']['article_link'], array(
'controller' => 'posts',
'action' => 'view',
'inline' => false,
'escape' => false,
$post['Post']['id']
));
?>
</td>
<td>
<?php
echo $this->Html->link('Edit', array(
'action' => 'edit',
$post['Post']['id']
));
?>
<?php
echo $this->Form->postLink('Delete', array(
'action' => 'delete',
$post['Post']['id']
), array(
'confirm' => 'Are you sure?'
));
?>
</td>
</tr>
<?php
endforeach;
?>
<?php
unset($post);
?>
</table>
感謝您的參考資料!應儘量仔細放置逃逸以避免跨站點腳本。 –