English 中文(简体)
《刑法》承认: Anchor or ahref?
原标题:CodeIgniter: Anchor or a href?

Whats difference in using anchor in CodeIgniter instead of using traditional html a href tag? Should I use anchor in Views or HTML a href? Thanks

最佳回答

我诚然认为,没有什么区别。 我个人使用html,因为它使用了更多的html。

如果你想在某种观点中添加背景道路,那么就这样做了:

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

However, one of the advantages of using codeigniter anchor is that, if you want to build contents dynamically:

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

is easier than

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

你们是否看到这种区别?

问题回答

anchor in CodeIgniter can do things like prefix the context path, so you just need to provide the URL of your controller (e.g. /login ) rather than the whole path to your application.

When you use A HREF, you have to ensure your paths are always relative or include the entire path to your app (i.e. /someapp/login).





相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签