024.CI4框架CodeIgniter辅助函数类之:URL辅助函数
2021-04-13 13:28
标签:自带 好用 ignite tle name style ace The segment 01. PHP的CI4框架自带了很多好用的URL辅助函数,我选择了以下这些比较常用的列了出来,代码如下: 02.效果如下 原创不易,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢。 024.CI4框架CodeIgniter辅助函数类之:URL辅助函数 标签:自带 好用 ignite tle name style ace The segment 原文地址:https://www.cnblogs.com/tianpan2019/p/12387282.htmlphp namespace App\Controllers;
// http://127.0.0.1/CI4/public/index.php/hello/
class Hello extends BaseController
{
public function index()
{
//http://localhost/CI4/index.php/news/local/123 0
echo site_url(‘news/local/123‘) . ‘ 0
‘;
//http://localhost/CI4/index.php/news/local/123 1
$segments = array(‘news‘, ‘local‘, ‘123‘);
echo site_url($segments) . ‘ 1
‘;
//http://localhost/CI4 2
echo base_url() . ‘ 2
‘;
//http://localhost/CI4/blog/post/123 3
echo base_url("blog/post/123") . ‘ 3
‘;
//http://localhost/CI4/images/icons/edit.png 4
echo base_url("images/icons/edit.png") . ‘ 4
‘;
//hello 5
echo uri_string() . ‘ 5
‘;
//http://localhost/CI4/hello 6
echo base_url(uri_string()) . ‘ 6
‘;
//hello 7
echo uri_string(‘http://some-site.com/blog/comments/123‘) . ‘ 7
‘;
//index.php 8
echo index_page() . ‘ 8
‘;
//My News 9
echo anchor(‘news/local/123‘, ‘My News‘, ‘title="News title"‘) . ‘ 9
‘;
//My News 10
echo anchor(‘news/local/123‘, ‘My News‘, array(‘title‘ => ‘The best news!‘)) . ‘ 10
‘;
//Click here 11
echo anchor(‘‘, ‘Click here‘) . ‘ 11
‘;
}
}
下一篇:使用layui上传控件问题
文章标题:024.CI4框架CodeIgniter辅助函数类之:URL辅助函数
文章链接:http://soscw.com/index.php/essay/75218.html