@52fhy
2016-04-28T11:52:28.000000Z
字数 905
阅读 478
PHP
<?php echo base_url() ?>style/alogin.css
等效于:http://localhost/ydr/style/alogin.css
也就是base_url()等效于项目根目录:http://localhost/ydr/
<?php echo site_url('admin/login/change_code'); ?>
等效于http://localhost/ydr/index.php/admin/login/change_code.shtml
也就是site_url()会自动封装当前模块的当前控制器方法,类似于thinkphp的大U方法。
示例:
echo site_url("news/local/123");//上面的例子将返回: http://example.com/index.php/news/local/123
echo base_url("news/post/123");//上面的例子将返回: http://example.com/news/post/123
它有三个可选参数:
anchor(uri segments, text, attributes)
示例:
echo anchor('news/local/123', 'My News', 'title="News title"');
输出:
<a href="http://example.com/index.php/news/local/123" title="News title">My News</a>
<?php echo form_open('admin/login/dologin'); ?>
等效于:
<form action="http://localhost/ydr/index.php/admin/login/dologin.shtml" method="post" accept-charset="utf-8">