CodeIgniter: Anchor or href?

What is the difference between using anchorCodeIgniter instead of the traditional html tag a href? Should I use binding in views or href HTML file? Thanks

+3
source share
2 answers

I honestly feel that there is minimal difference. I personally use the html anchor because it uses more html.

If you want to add the context path inside the view, simply do the following:

<a href="<?=site_url('path/name');?>">anchor</a>

However, one of the advantages of using codeigniter bindings is that if you want to dynamically create content:

for($i = 0; $i < $count; $i++) {
   $anchors[] = anchor('path/name', 'anchor');
}

easier than

for($i = 0; $i < $count; $i++) {
   $anchors[] = '<a href="'.site_url('path/name').'">anchor</a>';
}

Do you see the difference? :)

+5
source

anchor CodeIgniter , , URL (, '/login'), .

A HREF, , (,/someapp/login).

+2

All Articles