Justin John
Justin John

Reputation: 9615

End span tag in cake php using Html helper

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> . 

Upvotes: 1

Views: 1681

Answers (2)

dhofstet
dhofstet

Reputation: 9964

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.

Upvotes: 1

Karol
Karol

Reputation: 1254

You can also do this:

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

Upvotes: 2

Related Questions