<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # URL 輔助函數 URL 輔助函數文件包含了一些幫助你處理 URL 的函數。 [TOC=2,3] ## [加載輔助函數](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#id3) 該輔助函數通過下面的代碼加載: ~~~ $this->load->helper('url'); ~~~ ## [可用函數](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#id4) 該輔助函數有下列可用函數: site_url([$uri = ''[,?$protocol = NULL]]) 參數: * **$uri**?(string) -- URI string * **$protocol**?(string) -- Protocol, e.g. 'http' or 'https' 返回: Site URL 返回類型: string 根據配置文件返回你的站點 URL 。index.php (獲取其他你在配置文件中設置的?**index_page**?參數) 將會包含在你的 URL 中,另外再加上你傳給函數的 URI 參數,以及配置文件中設置的?**url_suffix**?參數。 推薦在任何時候都使用這種方法來生成你的 URL ,這樣在你的 URL 變動時你的代碼將具有可移植性。 傳給函數的 URI 段參數可以是一個字符串,也可以是個數組,下面是字符串的例子: ~~~ echo site_url('news/local/123'); ~~~ 上例將返回類似于:http://example.com/index.php/news/local/123 下面是使用數組的例子: ~~~ $segments = array('news', 'local', '123'); echo site_url($segments); ~~~ 該函數是?CI_Config::site_url()?的別名,更多信息請查閱?[配置類](http://codeigniter.org.cn/user_guide/libraries/config.html)?文檔。 base_url($uri = '',?$protocol = NULL) 參數: * **$uri**?(string) -- URI string * **$protocol**?(string) -- Protocol, e.g. 'http' or 'https' 返回: Base URL 返回類型: string 根據配置文件返回你站點的根 URL ,例如: ~~~ echo base_url(); ~~~ 該函數和?[site_url()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#site_url "site_url")?函數相同,只是不會在 URL 的后面加上?index_page?或?url_suffix?。 另外,和?[site_url()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#site_url "site_url")?一樣的是,你也可以使用字符串或數組格式的 URI 段。下面是字符串的例子: ~~~ echo base_url("blog/post/123"); ~~~ 上例將返回類似于:http://example.com/blog/post/123 跟?[site_url()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#site_url "site_url")?函數不一樣的是,你可以指定一個文件路徑(例如圖片或樣式文件),這將很有用,例如: ~~~ echo base_url("images/icons/edit.png"); ~~~ 將返回類似于:http://example.com/images/icons/edit.png 該函數是?CI_Config::base_url()?的別名,更多信息請查閱?[配置類](http://codeigniter.org.cn/user_guide/libraries/config.html)?文檔。 current_url() 返回: The current URL 返回類型: string 返回當前正在瀏覽的頁面的完整 URL (包括分段)。 注解 該函數和調用下面的代碼效果是一樣的: site_url(uri_string()); uri_string() 返回: An URI string 返回類型: string 返回包含該函數的頁面的 URI 分段。例如,如果你的 URL 是: ~~~ http://some-site.com/blog/comments/123 ~~~ 函數將返回: ~~~ blog/comments/123 ~~~ 該函數是?CI_Config::uri_string()?的別名,更多信息請查閱?[配置類](http://codeigniter.org.cn/user_guide/libraries/config.html)?文檔。 index_page() 返回: 'index_page' value 返回類型: mixed 返回你在配置文件中配置的?**index_page**?參數,例如: ~~~ echo index_page(); ~~~ anchor($uri = '',?$title = '',?$attributes = '') 參數: * **$uri**?(string) -- URI string * **$title**?(string) -- Anchor title * **$attributes**?(mixed) -- HTML attributes 返回: HTML hyperlink (anchor tag) 返回類型: string 根據你提供的 URL 生成一個標準的 HTML 鏈接。 第一個參數可以包含任何你想添加到 URL 上的段,和上面的?[site_url()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#site_url "site_url")?函數一樣,URL 的段可以是字符串或數組。 注解 如果你創建的鏈接是指向你自己的應用程序,那么不用包含根 URL (http&#58;//...)。 這個會根據你的配置文件自動添加到 URL 前面。所以你只需指定要添加的 URL 段就可以了。 第二個參數是鏈接的文本,如果留空,將使用鏈接本身作為文本。 第三個參數為你希望添加到鏈接的屬性,可以是一個字符串,也可以是個關聯數組。 這里是一些例子: ~~~ echo anchor('news/local/123', 'My News', 'title="News title"'); // Prints: <a href="http://example.com/index.php/news/local/123" title="News title">My News</a> echo anchor('news/local/123', 'My News', array('title' => 'The best news!')); // Prints: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a> echo anchor('', 'Click here'); // Prints: <a href="http://example.com">Click Here</a> ~~~ anchor_popup($uri = '',?$title = '',?$attributes = FALSE) 參數: * **$uri**?(string) -- URI string * **$title**?(string) -- Anchor title * **$attributes**?(mixed) -- HTML attributes 返回: Pop-up hyperlink 返回類型: string 和?[anchor()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#anchor "anchor")?函數非常類似,只是它生成的 URL 將會在新窗口被打開。你可以通過第三個參數指定 JavaScript 的窗口屬性,以此來控制窗口將如何被打開。如果沒有設置第三個參數,將會使用你的瀏覽器設置打開 一個新窗口。 這里是屬性的例子: ~~~ $atts = array( 'width' => 800, 'height' => 600, 'scrollbars' => 'yes', 'status'???? ?=> 'yes', 'resizable'? ?=> 'yes', 'screenx' => 0, 'screeny' => 0, 'window_name' => '_blank' ); echo anchor_popup('news/local/123', 'Click Me!', $atts); ~~~ 注解 上面的屬性是函數的默認值,所以你只需要設置和你想要的不一樣的參數。如果想使用所有默認的參數, 只要簡單的傳一個空數組即可: echo anchor_popup('news/local/123', 'Click Me!', array()); 注解 **window_name**?其實并不算一個屬性,而是 Javascript 的?window.open() ?函數的一個參數而已, 該函數接受一個窗口名稱或一個 window 對象。 注解 任何不同于上面列出來的其他的屬性將會作為 HTML 鏈接的屬性。 mailto($email,?$title = '',?$attributes = '') 參數: * **$email**?(string) -- E-mail address * **$title**?(string) -- Anchor title * **$attributes**?(mixed) -- HTML attributes 返回: A "mail to" hyperlink 返回類型: string 創建一個標準的 HTML e-mail 鏈接。例如: ~~~ echo mailto('me@my-site.com', 'Click Here to Contact Me'); ~~~ 和上面的?[anchor()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#anchor "anchor")?函數一樣,你可以通過第三個參數設置屬性: ~~~ $attributes = array('title' => 'Mail me'); echo mailto('me@my-site.com', 'Contact Me', $attributes); ~~~ safe_mailto($email,?$title = '',?$attributes = '') 參數: * **$email**?(string) -- E-mail address * **$title**?(string) -- Anchor title * **$attributes**?(mixed) -- HTML attributes 返回: A spam-safe "mail to" hyperlink 返回類型: string 和?[mailto()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#mailto "mailto")?函數一樣,但是它的?mailto?標簽使用了一個混淆的寫法, 可以防止你的 e-mail 地址被垃圾郵件機器人爬到。 auto_link($str,?$type = 'both',?$popup = FALSE) 參數: * **$str**?(string) -- Input string * **$type**?(string) -- Link type ('email', 'url' or 'both') * **$popup**?(bool) -- Whether to create popup links 返回: Linkified string 返回類型: string 將一個字符串中的 URL 和 e-mail 地址自動轉換為鏈接,例如: ~~~ $string = auto_link($string); ~~~ 第二個參數用于決定是轉換 URL 還是 e-mail 地址,默認情況不指定該參數,兩者都會被轉換。 E-mail 地址的鏈接是使用上面介紹的[safe_mailto()](http://codeigniter.org.cn/user_guide/helpers/url_helper.html#safe_mailto "safe_mailto")?函數生成的。 只轉換 URL ~~~ $string = auto_link($string, 'url'); ~~~ 只轉換 e-mail 地址: ~~~ $string = auto_link($string, 'email'); ~~~ 第三個參數用于指定鏈接是否要在新窗口打開。可以是布爾值 TRUE 或 FALSE ~~~ $string = auto_link($string, 'both', TRUE); ~~~ url_title($str,?$separator = '-',?$lowercase = FALSE) 參數: * **$str**?(string) -- Input string * **$separator**?(string) -- Word separator * **$lowercase**?(string) -- Whether to transform the output string to lower-case 返回: URL-formatted string 返回類型: string 將字符串轉換為對人類友好的 URL 字符串格式。例如,如果你有一個博客,你希望使用博客的標題作為 URL , 這時該函數很有用。例如: ~~~ $title = "What's wrong with CSS?"; $url_title = url_title($title); // Produces: Whats-wrong-with-CSS ~~~ 第二個參數指定分隔符,默認使用連字符。一般的選擇有:**-**?(連字符) 或者?**_**?(下劃線) 例如: ~~~ $title = "What's wrong with CSS?"; $url_title = url_title($title, 'underscore'); // Produces: Whats_wrong_with_CSS ~~~ 注解 第二個參數連字符和下劃線的老的用法已經廢棄。 第三個參數指定是否強制轉換為小寫。默認不會,參數類型為布爾值 TRUE 或 FALSE 。 例如: ~~~ $title = "What's wrong with CSS?"; $url_title = url_title($title, 'underscore', TRUE); // Produces: whats_wrong_with_css ~~~ prep_url($str = '') 參數: * **$str**?(string) -- URL string 返回: Protocol-prefixed URL string 返回類型: string 當 URL 中缺少協議前綴部分時,使用該函數將會向 URL 中添加 http&#58;// 。 像下面這樣使用該函數: ~~~ $url = prep_url('example.com'); ~~~ redirect($uri = '',?$method = 'auto',?$code = NULL) 參數: * **$uri**?(string) -- URI string * **$method**?(string) -- Redirect method ('auto', 'location' or 'refresh') * **$code**?(string) -- HTTP Response code (usually 302 or 303) 返回類型: void 通過 HTTP 頭重定向到指定 URL 。你可以指定一個完整的 URL ,也可以指定一個 URL 段, 該函數會根據配置文件自動生成改 URL 。 第二個參數用于指定一種重定向方法。可用的方法有:**auto**?、?**location**?和?**refresh**?。 location 方法速度快,但是在 ISS 服務器上不可靠。默認值為**auto**?,它會根據你的服務器環境 智能的選擇使用哪種方法。 第三個參數可選,允許你發送一個指定的 HTTP 狀態碼,這個可以用來為搜索引擎創建 301 重定向。 默認的狀態碼為 302 ,該參數只適用于**location**?重定向方法,對于?refresh?方法無效。例如: ~~~ if ($logged_in == FALSE) { redirect('/login/form/'); } // with 301 redirect redirect('/article/13', 'location', 301); ~~~ 注解 為了讓該函數有效,它必須在任何內容輸出到瀏覽器之前被調用。因為輸出內容會使用服務器 HTTP 頭。 注解 為了更好的控制服務器頭,你應該使用?輸出類 ?的?set_header()?方法。 注解 使用 IIS 的用戶要注意,如果你隱藏了?Server?這個 HTTP 頭,?auto?方法將無法檢測到 IIS 。 在這種情況下,推薦你使用?**refresh**?方法。 注解 當使用 HTTP/1.1 的 POST 來訪問你的頁面時,如果你使用的是?**location**?方法,會自動使用 HTTP 303 狀態碼。 重要 該函數會終止腳本的執行。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看