donpb2823 2013-12-24 17:42
浏览 25
已采纳

CodeIgniter站点URL和基本URL之间的区别

Hello What is the difference between SiteUrl() and BaseUrl() ? In my previous project it is base url but now in my new project it is Siteurl.Why this happens? Is baseurl() is an outdated one

  • 写回答

3条回答 默认 最新

  • dth54864 2013-12-24 17:49
    关注

    To clear all your doubts you have to read CodeIgniter Manual.Please Click Here

    base URL

    Returns your site base URL, as specified in your config file. Example: echo base_url();

    This function returns the same thing as site_url, without the index_page or url_suffix being appended.

    Also like site_url, you can supply segments as a string or an array. Here is a string example: echo base_url("blog/post/123");

    site URL

    Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your site index_page in your config file) will be added to the URL, as will any URI segments you pass to the function, and the url_suffix as set in your config file.

    You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable in the event your URL changes.

    Segments can be optionally passed to the function as a string or an array. Here is a string example: echo site_url("news/local/123");

    The above example would return something like: http://example.com/index.php/news/local/123

    Here is an example of segments passed as an array: $segments = array('news', 'local', '123');

    echo site_url($segments);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?