1
votes

How to end the tag in cake php

It is given in cake tutorial the below span tag will be formed by html helper, when text is given null.

<?php echo $this->Html->tag('span', null, array('class' => 'welcome'));?>
//Output
<span class="welcome">

But, here no idea about ending span tag.How can it be given html helper

<span class="welcome">
    //inner elements
</span>

Is there anything in cake php html helper to close any element tags like

<?php echo $this->Html->tag('span', 'close') ?>

will output as

</span> . 
2

2 Answers

2
votes

You can also do this:

<?php
echo $html->tag("span", null);
... whatever ...
echo $html->tag("/span", null);
?>
1
votes

You have to provide an empty string "", instead of null, for the second parameter when calling the tag method. Otherwise, it just prints the start tag according to the API docs.