zoukankan      html  css  js  c++  java
  • 024.CI4框架CodeIgniter辅助函数类之:URL辅助函数

    01. PHP的CI4框架自带了很多好用的URL辅助函数,我选择了以下这些比较常用的列了出来,代码如下:

    <?php namespace AppControllers;
    
    // 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<br>';
            //http://localhost/CI4/index.php/news/local/123 1
            $segments = array('news', 'local', '123');
            echo site_url($segments) . ' 1<br>';
            //http://localhost/CI4 2
            echo base_url() . ' 2<br>';
            //http://localhost/CI4/blog/post/123 3
            echo base_url("blog/post/123") . ' 3<br>';
            //http://localhost/CI4/images/icons/edit.png 4
            echo base_url("images/icons/edit.png") . ' 4<br>';
            //hello 5
            echo uri_string() . ' 5<br>';
            //http://localhost/CI4/hello 6
            echo base_url(uri_string()) . ' 6<br>';
            //hello 7
            echo uri_string('http://some-site.com/blog/comments/123') . ' 7<br>';
            //index.php 8
            echo index_page() . ' 8<br>';
            //My News 9
            echo anchor('news/local/123', 'My News', 'title="News title"') . ' 9<br>';
            //My News 10
            echo anchor('news/local/123', 'My News', array('title' => 'The best news!')) . ' 10<br>';
            //Click here 11
            echo anchor('', 'Click here') . ' 11<br>';
        }
    }

    02.效果如下

    原创不易,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢。

  • 相关阅读:
    WPF 本地化语言设置
    WPF 调节树状图滚动条值
    WPF中ListBox的使用注意事项
    SQL 树状结构表中查出所所有父级/子级
    Vue创建
    wpf 控件注意事项
    链表习题(1)-设计一个递归算法,删除不带头结点的单链表L中所有值为x的结点
    排序-快速排序
    排序-堆排序
    图-图的遍历
  • 原文地址:https://www.cnblogs.com/tianpan2019/p/12387282.html
Copyright © 2011-2022 走看看