CodeIgniter - 在视图中链接到另一个页面的正确方法 [英] CodeIgniter - Correct way to link to another page in a view
本文介绍了CodeIgniter - 在视图中链接到另一个页面的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人可以告诉我从视图中链接到另一个页面的正确方法.
I was wondering if someone could tell me the correct way to link to another page from within a view.
是否有此功能或只是通常的功能
Is there a function for this or is it just the usual about
干杯,
推荐答案
我认为您的意思是应用程序中的内部".
您可以创建自己的 标签并像这样在 href 中插入一个 url
you can create your own <a>
tag and insert a url in the href like this
<a href="<?php echo site_url('controller/function/uri') ?>">Link</a>
或者您可以通过这种方式使用 URL 助手来生成 <a>
标签
OR you can use the URL helper this way to generate an <a>
tag
anchor(uri segments, text, attributes)
所以...使用它...
So... to use it...
<?php echo anchor('controller/function/uri', 'Link', 'class="link-class"') ?>
这会产生
<a href="http://domain.com/index.php/controller/function/uri" class="link-class">Link</a>
对于附加评论的问题
我会用我的第一个例子
所以...
<a href="<?php echo site_url('controller/function') ?>"><img src="<?php echo base_url() ?>img/path/file.jpg" /></a>
对于图像(和其他资产),我不会将文件路径放在 php 中,我只会回显 base_url() 然后正常添加路径.
for images (and other assets) I wouldn't put the file path within the php, I would just echo the base_url() and then add the path normally.
这篇关于CodeIgniter - 在视图中链接到另一个页面的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文