url_helper.html 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>URL Helper &mdash; CodeIgniter 3.1.11 documentation</title>
  8. <link rel="shortcut icon" href="../_static/ci-icon.ico"/>
  9. <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
  10. <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
  11. <link rel="index" title="Index"
  12. href="../genindex.html"/>
  13. <link rel="search" title="Search" href="../search.html"/>
  14. <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/>
  15. <link rel="up" title="Helpers" href="index.html"/>
  16. <link rel="next" title="XML Helper" href="xml_helper.html"/>
  17. <link rel="prev" title="Typography Helper" href="typography_helper.html"/>
  18. <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
  19. </head>
  20. <body class="wy-body-for-nav" role="document">
  21. <div id="nav">
  22. <div id="nav_inner">
  23. <div id="pulldown-menu" class="ciNav">
  24. <ul>
  25. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  26. </ul>
  27. <ul>
  28. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  29. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  30. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  31. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  32. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  33. </ul>
  34. </li>
  35. </ul>
  36. <ul>
  37. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  38. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  39. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. <ul>
  48. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  53. </ul>
  54. </li>
  55. </ul>
  56. <ul>
  57. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  58. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  59. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  60. </ul>
  61. </li>
  62. </ul>
  63. <ul>
  64. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  65. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  66. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  67. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  68. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  69. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  70. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  71. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  72. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  73. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  74. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  75. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  76. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  77. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  78. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  79. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  80. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  81. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  82. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  83. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  84. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  85. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  86. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  87. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  88. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  89. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  90. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  91. </ul>
  92. </li>
  93. </ul>
  94. <ul>
  95. <li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a><ul>
  96. <li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">Benchmarking Class</a></li>
  97. <li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
  98. <li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">Calendaring Class</a></li>
  99. <li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">Shopping Cart Class</a></li>
  100. <li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">Config Class</a></li>
  101. <li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
  102. <li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">Encrypt Class</a></li>
  103. <li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Library</a></li>
  104. <li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">File Uploading Class</a></li>
  105. <li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">Form Validation</a></li>
  106. <li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP Class</a></li>
  107. <li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">Image Manipulation Class</a></li>
  108. <li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">Input Class</a></li>
  109. <li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript Class</a></li>
  110. <li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">Language Class</a></li>
  111. <li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">Loader Class</a></li>
  112. <li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">Migrations Class</a></li>
  113. <li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">Output Class</a></li>
  114. <li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination Class</a></li>
  115. <li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">Template Parser Class</a></li>
  116. <li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
  117. <li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
  118. <li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML Table Class</a></li>
  119. <li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">Trackback Class</a></li>
  120. <li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography Class</a></li>
  121. <li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">Unit Testing Class</a></li>
  122. <li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI Class</a></li>
  123. <li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
  124. <li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
  125. <li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip Encoding Class</a></li>
  126. </ul>
  127. </li>
  128. </ul>
  129. <ul>
  130. <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
  131. <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
  132. <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
  133. <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
  134. <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
  135. <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
  136. <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
  137. <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
  138. <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
  139. <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
  140. <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
  141. <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
  142. <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
  143. <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
  144. <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
  145. </ul>
  146. </li>
  147. </ul>
  148. <ul class="current">
  149. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Helpers</a><ul class="current">
  150. <li class="toctree-l2"><a class="reference internal" href="array_helper.html">Array Helper</a></li>
  151. <li class="toctree-l2"><a class="reference internal" href="captcha_helper.html">CAPTCHA Helper</a></li>
  152. <li class="toctree-l2"><a class="reference internal" href="cookie_helper.html">Cookie Helper</a></li>
  153. <li class="toctree-l2"><a class="reference internal" href="date_helper.html">Date Helper</a></li>
  154. <li class="toctree-l2"><a class="reference internal" href="directory_helper.html">Directory Helper</a></li>
  155. <li class="toctree-l2"><a class="reference internal" href="download_helper.html">Download Helper</a></li>
  156. <li class="toctree-l2"><a class="reference internal" href="email_helper.html">Email Helper</a></li>
  157. <li class="toctree-l2"><a class="reference internal" href="file_helper.html">File Helper</a></li>
  158. <li class="toctree-l2"><a class="reference internal" href="form_helper.html">Form Helper</a></li>
  159. <li class="toctree-l2"><a class="reference internal" href="html_helper.html">HTML Helper</a></li>
  160. <li class="toctree-l2"><a class="reference internal" href="inflector_helper.html">Inflector Helper</a></li>
  161. <li class="toctree-l2"><a class="reference internal" href="language_helper.html">Language Helper</a></li>
  162. <li class="toctree-l2"><a class="reference internal" href="number_helper.html">Number Helper</a></li>
  163. <li class="toctree-l2"><a class="reference internal" href="path_helper.html">Path Helper</a></li>
  164. <li class="toctree-l2"><a class="reference internal" href="security_helper.html">Security Helper</a></li>
  165. <li class="toctree-l2"><a class="reference internal" href="smiley_helper.html">Smiley Helper</a></li>
  166. <li class="toctree-l2"><a class="reference internal" href="string_helper.html">String Helper</a></li>
  167. <li class="toctree-l2"><a class="reference internal" href="text_helper.html">Text Helper</a></li>
  168. <li class="toctree-l2"><a class="reference internal" href="typography_helper.html">Typography Helper</a></li>
  169. <li class="toctree-l2 current"><a class="current reference internal" href="#">URL Helper</a></li>
  170. <li class="toctree-l2"><a class="reference internal" href="xml_helper.html">XML Helper</a></li>
  171. </ul>
  172. </li>
  173. </ul>
  174. </div>
  175. </div>
  176. </div>
  177. <div id="nav2">
  178. <a href="#" id="openToc">
  179. <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" />
  180. </a>
  181. </div>
  182. <div class="wy-grid-for-nav">
  183. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  184. <div class="wy-side-nav-search">
  185. <a href="../index.html" class="fa fa-home"> CodeIgniter</a>
  186. <div role="search">
  187. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  188. <input type="text" name="q" placeholder="Search docs" />
  189. <input type="hidden" name="check_keywords" value="yes" />
  190. <input type="hidden" name="area" value="default" />
  191. </form>
  192. </div>
  193. </div>
  194. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  195. <ul>
  196. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  197. </ul>
  198. <ul>
  199. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  200. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  201. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  202. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  203. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  204. </ul>
  205. </li>
  206. </ul>
  207. <ul>
  208. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  209. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  210. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  211. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  212. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  213. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  214. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  215. </ul>
  216. </li>
  217. </ul>
  218. <ul>
  219. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  220. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  221. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  222. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  223. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  224. </ul>
  225. </li>
  226. </ul>
  227. <ul>
  228. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  229. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  230. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  231. </ul>
  232. </li>
  233. </ul>
  234. <ul>
  235. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  236. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  237. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  238. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  239. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  240. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  241. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  242. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  243. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  244. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  245. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  246. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  247. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  248. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  249. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  250. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  251. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  252. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  253. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  254. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  255. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  256. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  257. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  258. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  259. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  260. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  261. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  262. </ul>
  263. </li>
  264. </ul>
  265. <ul>
  266. <li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a><ul>
  267. <li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">Benchmarking Class</a></li>
  268. <li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
  269. <li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">Calendaring Class</a></li>
  270. <li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">Shopping Cart Class</a></li>
  271. <li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">Config Class</a></li>
  272. <li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
  273. <li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">Encrypt Class</a></li>
  274. <li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Library</a></li>
  275. <li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">File Uploading Class</a></li>
  276. <li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">Form Validation</a></li>
  277. <li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP Class</a></li>
  278. <li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">Image Manipulation Class</a></li>
  279. <li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">Input Class</a></li>
  280. <li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript Class</a></li>
  281. <li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">Language Class</a></li>
  282. <li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">Loader Class</a></li>
  283. <li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">Migrations Class</a></li>
  284. <li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">Output Class</a></li>
  285. <li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination Class</a></li>
  286. <li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">Template Parser Class</a></li>
  287. <li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
  288. <li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
  289. <li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML Table Class</a></li>
  290. <li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">Trackback Class</a></li>
  291. <li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography Class</a></li>
  292. <li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">Unit Testing Class</a></li>
  293. <li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI Class</a></li>
  294. <li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
  295. <li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
  296. <li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip Encoding Class</a></li>
  297. </ul>
  298. </li>
  299. </ul>
  300. <ul>
  301. <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
  302. <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
  303. <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
  304. <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
  305. <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
  306. <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
  307. <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
  308. <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
  309. <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
  310. <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
  311. <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
  312. <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
  313. <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
  314. <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
  315. <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
  316. </ul>
  317. </li>
  318. </ul>
  319. <ul class="current">
  320. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Helpers</a><ul class="current">
  321. <li class="toctree-l2"><a class="reference internal" href="array_helper.html">Array Helper</a></li>
  322. <li class="toctree-l2"><a class="reference internal" href="captcha_helper.html">CAPTCHA Helper</a></li>
  323. <li class="toctree-l2"><a class="reference internal" href="cookie_helper.html">Cookie Helper</a></li>
  324. <li class="toctree-l2"><a class="reference internal" href="date_helper.html">Date Helper</a></li>
  325. <li class="toctree-l2"><a class="reference internal" href="directory_helper.html">Directory Helper</a></li>
  326. <li class="toctree-l2"><a class="reference internal" href="download_helper.html">Download Helper</a></li>
  327. <li class="toctree-l2"><a class="reference internal" href="email_helper.html">Email Helper</a></li>
  328. <li class="toctree-l2"><a class="reference internal" href="file_helper.html">File Helper</a></li>
  329. <li class="toctree-l2"><a class="reference internal" href="form_helper.html">Form Helper</a></li>
  330. <li class="toctree-l2"><a class="reference internal" href="html_helper.html">HTML Helper</a></li>
  331. <li class="toctree-l2"><a class="reference internal" href="inflector_helper.html">Inflector Helper</a></li>
  332. <li class="toctree-l2"><a class="reference internal" href="language_helper.html">Language Helper</a></li>
  333. <li class="toctree-l2"><a class="reference internal" href="number_helper.html">Number Helper</a></li>
  334. <li class="toctree-l2"><a class="reference internal" href="path_helper.html">Path Helper</a></li>
  335. <li class="toctree-l2"><a class="reference internal" href="security_helper.html">Security Helper</a></li>
  336. <li class="toctree-l2"><a class="reference internal" href="smiley_helper.html">Smiley Helper</a></li>
  337. <li class="toctree-l2"><a class="reference internal" href="string_helper.html">String Helper</a></li>
  338. <li class="toctree-l2"><a class="reference internal" href="text_helper.html">Text Helper</a></li>
  339. <li class="toctree-l2"><a class="reference internal" href="typography_helper.html">Typography Helper</a></li>
  340. <li class="toctree-l2 current"><a class="current reference internal" href="#">URL Helper</a></li>
  341. <li class="toctree-l2"><a class="reference internal" href="xml_helper.html">XML Helper</a></li>
  342. </ul>
  343. </li>
  344. </ul>
  345. </div>
  346. &nbsp;
  347. </nav>
  348. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  349. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  350. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  351. <a href="../index.html">CodeIgniter</a>
  352. </nav>
  353. <div class="wy-nav-content">
  354. <div class="rst-content">
  355. <div role="navigation" aria-label="breadcrumbs navigation">
  356. <ul class="wy-breadcrumbs">
  357. <li><a href="../index.html">Docs</a> &raquo;</li>
  358. <li><a href="index.html">Helpers</a> &raquo;</li>
  359. <li>URL Helper</li>
  360. <li class="wy-breadcrumbs-aside">
  361. </li>
  362. <div style="float:right;margin-left:5px;" id="closeMe">
  363. <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" />
  364. </div>
  365. </ul>
  366. <hr/>
  367. </div>
  368. <div role="main" class="document">
  369. <div class="section" id="url-helper">
  370. <h1>URL Helper<a class="headerlink" href="#url-helper" title="Permalink to this headline">¶</a></h1>
  371. <p>The URL Helper file contains functions that assist in working with URLs.</p>
  372. <div class="contents local topic" id="contents">
  373. <ul class="simple">
  374. <li><a class="reference internal" href="#loading-this-helper" id="id1">Loading this Helper</a></li>
  375. <li><a class="reference internal" href="#available-functions" id="id2">Available Functions</a></li>
  376. </ul>
  377. </div>
  378. <div class="custom-index container"></div><div class="section" id="loading-this-helper">
  379. <h2><a class="toc-backref" href="#id1">Loading this Helper</a><a class="headerlink" href="#loading-this-helper" title="Permalink to this headline">¶</a></h2>
  380. <p>This helper is loaded using the following code:</p>
  381. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">helper</span><span class="p">(</span><span class="s1">&#39;url&#39;</span><span class="p">);</span>
  382. </pre></div>
  383. </div>
  384. </div>
  385. <div class="section" id="available-functions">
  386. <h2><a class="toc-backref" href="#id2">Available Functions</a><a class="headerlink" href="#available-functions" title="Permalink to this headline">¶</a></h2>
  387. <p>The following functions are available:</p>
  388. <dl class="function">
  389. <dt id="site_url">
  390. <code class="descname">site_url</code><span class="sig-paren">(</span><span class="optional">[</span><em>$uri = ''</em><span class="optional">[</span>, <em>$protocol = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#site_url" title="Permalink to this definition">¶</a></dt>
  391. <dd><table class="docutils field-list" frame="void" rules="none">
  392. <col class="field-name" />
  393. <col class="field-body" />
  394. <tbody valign="top">
  395. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  396. <li><strong>$uri</strong> (<em>string</em>) – URI string</li>
  397. <li><strong>$protocol</strong> (<em>string</em>) – Protocol, e.g. ‘http’ or ‘https’</li>
  398. </ul>
  399. </td>
  400. </tr>
  401. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Site URL</p>
  402. </td>
  403. </tr>
  404. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  405. </td>
  406. </tr>
  407. </tbody>
  408. </table>
  409. <p>Returns your site URL, as specified in your config file. The index.php
  410. file (or whatever you have set as your site <strong>index_page</strong> in your config
  411. file) will be added to the URL, as will any URI segments you pass to the
  412. function, plus the <strong>url_suffix</strong> as set in your config file.</p>
  413. <p>You are encouraged to use this function any time you need to generate a
  414. local URL so that your pages become more portable in the event your URL
  415. changes.</p>
  416. <p>Segments can be optionally passed to the function as a string or an
  417. array. Here is a string example:</p>
  418. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">site_url</span><span class="p">(</span><span class="s1">&#39;news/local/123&#39;</span><span class="p">);</span>
  419. </pre></div>
  420. </div>
  421. <p>The above example would return something like:
  422. <em>http://example.com/index.php/news/local/123</em></p>
  423. <p>Here is an example of segments passed as an array:</p>
  424. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$segments</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;news&#39;</span><span class="p">,</span> <span class="s1">&#39;local&#39;</span><span class="p">,</span> <span class="s1">&#39;123&#39;</span><span class="p">);</span>
  425. <span class="k">echo</span> <span class="nx">site_url</span><span class="p">(</span><span class="nv">$segments</span><span class="p">);</span>
  426. </pre></div>
  427. </div>
  428. <p>This function is an alias for <code class="docutils literal"><span class="pre">CI_Config::site_url()</span></code>. For more info,
  429. please see the <a class="reference internal" href="../libraries/config.html"><span class="doc">Config Library</span></a> documentation.</p>
  430. </dd></dl>
  431. <dl class="function">
  432. <dt id="base_url">
  433. <code class="descname">base_url</code><span class="sig-paren">(</span><em>$uri = ''</em>, <em>$protocol = NULL</em><span class="sig-paren">)</span><a class="headerlink" href="#base_url" title="Permalink to this definition">¶</a></dt>
  434. <dd><table class="docutils field-list" frame="void" rules="none">
  435. <col class="field-name" />
  436. <col class="field-body" />
  437. <tbody valign="top">
  438. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  439. <li><strong>$uri</strong> (<em>string</em>) – URI string</li>
  440. <li><strong>$protocol</strong> (<em>string</em>) – Protocol, e.g. ‘http’ or ‘https’</li>
  441. </ul>
  442. </td>
  443. </tr>
  444. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Base URL</p>
  445. </td>
  446. </tr>
  447. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  448. </td>
  449. </tr>
  450. </tbody>
  451. </table>
  452. <p>Returns your site base URL, as specified in your config file. Example:</p>
  453. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">base_url</span><span class="p">();</span>
  454. </pre></div>
  455. </div>
  456. <p>This function returns the same thing as <a class="reference internal" href="#site_url" title="site_url"><code class="xref php php-func docutils literal"><span class="pre">site_url()</span></code></a>, without
  457. the <em>index_page</em> or <em>url_suffix</em> being appended.</p>
  458. <p>Also like <a class="reference internal" href="#site_url" title="site_url"><code class="xref php php-func docutils literal"><span class="pre">site_url()</span></code></a>, you can supply segments as a string or
  459. an array. Here is a string example:</p>
  460. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">base_url</span><span class="p">(</span><span class="s2">&quot;blog/post/123&quot;</span><span class="p">);</span>
  461. </pre></div>
  462. </div>
  463. <p>The above example would return something like:
  464. <em>http://example.com/blog/post/123</em></p>
  465. <p>This is useful because unlike <a class="reference internal" href="#site_url" title="site_url"><code class="xref php php-func docutils literal"><span class="pre">site_url()</span></code></a>, you can supply a
  466. string to a file, such as an image or stylesheet. For example:</p>
  467. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">base_url</span><span class="p">(</span><span class="s2">&quot;images/icons/edit.png&quot;</span><span class="p">);</span>
  468. </pre></div>
  469. </div>
  470. <p>This would give you something like:
  471. <em>http://example.com/images/icons/edit.png</em></p>
  472. <p>This function is an alias for <code class="docutils literal"><span class="pre">CI_Config::base_url()</span></code>. For more info,
  473. please see the <a class="reference internal" href="../libraries/config.html"><span class="doc">Config Library</span></a> documentation.</p>
  474. </dd></dl>
  475. <dl class="function">
  476. <dt id="current_url">
  477. <code class="descname">current_url</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#current_url" title="Permalink to this definition">¶</a></dt>
  478. <dd><table class="docutils field-list" frame="void" rules="none">
  479. <col class="field-name" />
  480. <col class="field-body" />
  481. <tbody valign="top">
  482. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The current URL</td>
  483. </tr>
  484. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
  485. </tr>
  486. </tbody>
  487. </table>
  488. <p>Returns the full URL (including segments) of the page being currently
  489. viewed.</p>
  490. <div class="admonition note">
  491. <p class="first admonition-title">Note</p>
  492. <p class="last">Calling this function is the same as doing this:
  493. |
  494. | site_url(uri_string());</p>
  495. </div>
  496. </dd></dl>
  497. <dl class="function">
  498. <dt id="uri_string">
  499. <code class="descname">uri_string</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#uri_string" title="Permalink to this definition">¶</a></dt>
  500. <dd><table class="docutils field-list" frame="void" rules="none">
  501. <col class="field-name" />
  502. <col class="field-body" />
  503. <tbody valign="top">
  504. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An URI string</td>
  505. </tr>
  506. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
  507. </tr>
  508. </tbody>
  509. </table>
  510. <p>Returns the URI segments of any page that contains this function.
  511. For example, if your URL was this:</p>
  512. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">some</span><span class="o">-</span><span class="nx">site</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">blog</span><span class="o">/</span><span class="nx">comments</span><span class="o">/</span><span class="mi">123</span>
  513. </pre></div>
  514. </div>
  515. <p>The function would return:</p>
  516. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">blog</span><span class="o">/</span><span class="nx">comments</span><span class="o">/</span><span class="mi">123</span>
  517. </pre></div>
  518. </div>
  519. <p>This function is an alias for <code class="docutils literal"><span class="pre">CI_Config::uri_string()</span></code>. For more info,
  520. please see the <a class="reference internal" href="../libraries/config.html"><span class="doc">Config Library</span></a> documentation.</p>
  521. </dd></dl>
  522. <dl class="function">
  523. <dt id="index_page">
  524. <code class="descname">index_page</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#index_page" title="Permalink to this definition">¶</a></dt>
  525. <dd><table class="docutils field-list" frame="void" rules="none">
  526. <col class="field-name" />
  527. <col class="field-body" />
  528. <tbody valign="top">
  529. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">‘index_page’ value</td>
  530. </tr>
  531. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td>
  532. </tr>
  533. </tbody>
  534. </table>
  535. <p>Returns your site <strong>index_page</strong>, as specified in your config file.
  536. Example:</p>
  537. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">index_page</span><span class="p">();</span>
  538. </pre></div>
  539. </div>
  540. </dd></dl>
  541. <dl class="function">
  542. <dt id="anchor">
  543. <code class="descname">anchor</code><span class="sig-paren">(</span><em>$uri = ''</em>, <em>$title = ''</em>, <em>$attributes = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#anchor" title="Permalink to this definition">¶</a></dt>
  544. <dd><table class="docutils field-list" frame="void" rules="none">
  545. <col class="field-name" />
  546. <col class="field-body" />
  547. <tbody valign="top">
  548. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  549. <li><strong>$uri</strong> (<em>string</em>) – URI string</li>
  550. <li><strong>$title</strong> (<em>string</em>) – Anchor title</li>
  551. <li><strong>$attributes</strong> (<em>mixed</em>) – HTML attributes</li>
  552. </ul>
  553. </td>
  554. </tr>
  555. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML hyperlink (anchor tag)</p>
  556. </td>
  557. </tr>
  558. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  559. </td>
  560. </tr>
  561. </tbody>
  562. </table>
  563. <p>Creates a standard HTML anchor link based on your local site URL.</p>
  564. <p>The first parameter can contain any segments you wish appended to the
  565. URL. As with the <a class="reference internal" href="#site_url" title="site_url"><code class="xref php php-func docutils literal"><span class="pre">site_url()</span></code></a> function above, segments can
  566. be a string or an array.</p>
  567. <div class="admonition note">
  568. <p class="first admonition-title">Note</p>
  569. <p class="last">If you are building links that are internal to your application
  570. do not include the base URL (http://…). This will be added
  571. automatically from the information specified in your config file.
  572. Include only the URI segments you wish appended to the URL.</p>
  573. </div>
  574. <p>The second segment is the text you would like the link to say. If you
  575. leave it blank, the URL will be used.</p>
  576. <p>The third parameter can contain a list of attributes you would like
  577. added to the link. The attributes can be a simple string or an
  578. associative array.</p>
  579. <p>Here are some examples:</p>
  580. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">anchor</span><span class="p">(</span><span class="s1">&#39;news/local/123&#39;</span><span class="p">,</span> <span class="s1">&#39;My News&#39;</span><span class="p">,</span> <span class="s1">&#39;title=&quot;News title&quot;&#39;</span><span class="p">);</span>
  581. <span class="c1">// Prints: &lt;a href=&quot;http://example.com/index.php/news/local/123&quot; title=&quot;News title&quot;&gt;My News&lt;/a&gt;</span>
  582. <span class="k">echo</span> <span class="nx">anchor</span><span class="p">(</span><span class="s1">&#39;news/local/123&#39;</span><span class="p">,</span> <span class="s1">&#39;My News&#39;</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;title&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;The best news!&#39;</span><span class="p">));</span>
  583. <span class="c1">// Prints: &lt;a href=&quot;http://example.com/index.php/news/local/123&quot; title=&quot;The best news!&quot;&gt;My News&lt;/a&gt;</span>
  584. <span class="k">echo</span> <span class="nx">anchor</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;Click here&#39;</span><span class="p">);</span>
  585. <span class="c1">// Prints: &lt;a href=&quot;http://example.com&quot;&gt;Click Here&lt;/a&gt;</span>
  586. </pre></div>
  587. </div>
  588. </dd></dl>
  589. <dl class="function">
  590. <dt id="anchor_popup">
  591. <code class="descname">anchor_popup</code><span class="sig-paren">(</span><em>$uri = ''</em>, <em>$title = ''</em>, <em>$attributes = FALSE</em><span class="sig-paren">)</span><a class="headerlink" href="#anchor_popup" title="Permalink to this definition">¶</a></dt>
  592. <dd><table class="docutils field-list" frame="void" rules="none">
  593. <col class="field-name" />
  594. <col class="field-body" />
  595. <tbody valign="top">
  596. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  597. <li><strong>$uri</strong> (<em>string</em>) – URI string</li>
  598. <li><strong>$title</strong> (<em>string</em>) – Anchor title</li>
  599. <li><strong>$attributes</strong> (<em>mixed</em>) – HTML attributes</li>
  600. </ul>
  601. </td>
  602. </tr>
  603. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Pop-up hyperlink</p>
  604. </td>
  605. </tr>
  606. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  607. </td>
  608. </tr>
  609. </tbody>
  610. </table>
  611. <p>Nearly identical to the <a class="reference internal" href="#anchor" title="anchor"><code class="xref php php-func docutils literal"><span class="pre">anchor()</span></code></a> function except that it
  612. opens the URL in a new window. You can specify JavaScript window
  613. attributes in the third parameter to control how the window is opened.
  614. If the third parameter is not set it will simply open a new window with
  615. your own browser settings.</p>
  616. <p>Here is an example with attributes:</p>
  617. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$atts</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  618. <span class="s1">&#39;width&#39;</span> <span class="o">=&gt;</span> <span class="mi">800</span><span class="p">,</span>
  619. <span class="s1">&#39;height&#39;</span> <span class="o">=&gt;</span> <span class="mi">600</span><span class="p">,</span>
  620. <span class="s1">&#39;scrollbars&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;yes&#39;</span><span class="p">,</span>
  621. <span class="s1">&#39;status&#39;</span><span class="nx">    </span> <span class="nx"> </span><span class="o">=&gt;</span> <span class="s1">&#39;yes&#39;</span><span class="p">,</span>
  622. <span class="s1">&#39;resizable&#39;</span><span class="nx"> </span> <span class="nx"> </span><span class="o">=&gt;</span> <span class="s1">&#39;yes&#39;</span><span class="p">,</span>
  623. <span class="s1">&#39;screenx&#39;</span> <span class="o">=&gt;</span> <span class="mi">0</span><span class="p">,</span>
  624. <span class="s1">&#39;screeny&#39;</span> <span class="o">=&gt;</span> <span class="mi">0</span><span class="p">,</span>
  625. <span class="s1">&#39;window_name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;_blank&#39;</span>
  626. <span class="p">);</span>
  627. <span class="k">echo</span> <span class="nx">anchor_popup</span><span class="p">(</span><span class="s1">&#39;news/local/123&#39;</span><span class="p">,</span> <span class="s1">&#39;Click Me!&#39;</span><span class="p">,</span> <span class="nv">$atts</span><span class="p">);</span>
  628. </pre></div>
  629. </div>
  630. <div class="admonition note">
  631. <p class="first admonition-title">Note</p>
  632. <p class="last">The above attributes are the function defaults so you only need to
  633. set the ones that are different from what you need. If you want the
  634. function to use all of its defaults simply pass an empty array in the
  635. third parameter:
  636. |
  637. | echo anchor_popup(‘news/local/123’, ‘Click Me!’, array());</p>
  638. </div>
  639. <div class="admonition note">
  640. <p class="first admonition-title">Note</p>
  641. <p class="last">The <strong>window_name</strong> is not really an attribute, but an argument to
  642. the JavaScript <cite>window.open() &lt;http://www.w3schools.com/jsref/met_win_open.asp&gt;</cite>
  643. method, which accepts either a window name or a window target.</p>
  644. </div>
  645. <div class="admonition note">
  646. <p class="first admonition-title">Note</p>
  647. <p class="last">Any other attribute than the listed above will be parsed as an
  648. HTML attribute to the anchor tag.</p>
  649. </div>
  650. </dd></dl>
  651. <dl class="function">
  652. <dt id="mailto">
  653. <code class="descname">mailto</code><span class="sig-paren">(</span><em>$email</em>, <em>$title = ''</em>, <em>$attributes = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#mailto" title="Permalink to this definition">¶</a></dt>
  654. <dd><table class="docutils field-list" frame="void" rules="none">
  655. <col class="field-name" />
  656. <col class="field-body" />
  657. <tbody valign="top">
  658. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  659. <li><strong>$email</strong> (<em>string</em>) – E-mail address</li>
  660. <li><strong>$title</strong> (<em>string</em>) – Anchor title</li>
  661. <li><strong>$attributes</strong> (<em>mixed</em>) – HTML attributes</li>
  662. </ul>
  663. </td>
  664. </tr>
  665. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A “mail to” hyperlink</p>
  666. </td>
  667. </tr>
  668. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  669. </td>
  670. </tr>
  671. </tbody>
  672. </table>
  673. <p>Creates a standard HTML e-mail link. Usage example:</p>
  674. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">mailto</span><span class="p">(</span><span class="s1">&#39;me@my-site.com&#39;</span><span class="p">,</span> <span class="s1">&#39;Click Here to Contact Me&#39;</span><span class="p">);</span>
  675. </pre></div>
  676. </div>
  677. <p>As with the <a class="reference internal" href="#anchor" title="anchor"><code class="xref php php-func docutils literal"><span class="pre">anchor()</span></code></a> tab above, you can set attributes using the
  678. third parameter:</p>
  679. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$attributes</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;title&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Mail me&#39;</span><span class="p">);</span>
  680. <span class="k">echo</span> <span class="nx">mailto</span><span class="p">(</span><span class="s1">&#39;me@my-site.com&#39;</span><span class="p">,</span> <span class="s1">&#39;Contact Me&#39;</span><span class="p">,</span> <span class="nv">$attributes</span><span class="p">);</span>
  681. </pre></div>
  682. </div>
  683. </dd></dl>
  684. <dl class="function">
  685. <dt id="safe_mailto">
  686. <code class="descname">safe_mailto</code><span class="sig-paren">(</span><em>$email</em>, <em>$title = ''</em>, <em>$attributes = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#safe_mailto" title="Permalink to this definition">¶</a></dt>
  687. <dd><table class="docutils field-list" frame="void" rules="none">
  688. <col class="field-name" />
  689. <col class="field-body" />
  690. <tbody valign="top">
  691. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  692. <li><strong>$email</strong> (<em>string</em>) – E-mail address</li>
  693. <li><strong>$title</strong> (<em>string</em>) – Anchor title</li>
  694. <li><strong>$attributes</strong> (<em>mixed</em>) – HTML attributes</li>
  695. </ul>
  696. </td>
  697. </tr>
  698. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A spam-safe “mail to” hyperlink</p>
  699. </td>
  700. </tr>
  701. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  702. </td>
  703. </tr>
  704. </tbody>
  705. </table>
  706. <p>Identical to the <a class="reference internal" href="#mailto" title="mailto"><code class="xref php php-func docutils literal"><span class="pre">mailto()</span></code></a> function except it writes an obfuscated
  707. version of the <em>mailto</em> tag using ordinal numbers written with JavaScript to
  708. help prevent the e-mail address from being harvested by spam bots.</p>
  709. </dd></dl>
  710. <dl class="function">
  711. <dt id="auto_link">
  712. <code class="descname">auto_link</code><span class="sig-paren">(</span><em>$str</em>, <em>$type = 'both'</em>, <em>$popup = FALSE</em><span class="sig-paren">)</span><a class="headerlink" href="#auto_link" title="Permalink to this definition">¶</a></dt>
  713. <dd><table class="docutils field-list" frame="void" rules="none">
  714. <col class="field-name" />
  715. <col class="field-body" />
  716. <tbody valign="top">
  717. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  718. <li><strong>$str</strong> (<em>string</em>) – Input string</li>
  719. <li><strong>$type</strong> (<em>string</em>) – Link type (‘email’, ‘url’ or ‘both’)</li>
  720. <li><strong>$popup</strong> (<em>bool</em>) – Whether to create popup links</li>
  721. </ul>
  722. </td>
  723. </tr>
  724. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Linkified string</p>
  725. </td>
  726. </tr>
  727. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  728. </td>
  729. </tr>
  730. </tbody>
  731. </table>
  732. <p>Automatically turns URLs and e-mail addresses contained in a string into
  733. links. Example:</p>
  734. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nx">auto_link</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span>
  735. </pre></div>
  736. </div>
  737. <p>The second parameter determines whether URLs and e-mails are converted or
  738. just one or the other. Default behavior is both if the parameter is not
  739. specified. E-mail links are encoded as <a class="reference internal" href="#safe_mailto" title="safe_mailto"><code class="xref php php-func docutils literal"><span class="pre">safe_mailto()</span></code></a> as shown
  740. above.</p>
  741. <p>Converts only URLs:</p>
  742. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nx">auto_link</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="s1">&#39;url&#39;</span><span class="p">);</span>
  743. </pre></div>
  744. </div>
  745. <p>Converts only e-mail addresses:</p>
  746. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nx">auto_link</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="s1">&#39;email&#39;</span><span class="p">);</span>
  747. </pre></div>
  748. </div>
  749. <p>The third parameter determines whether links are shown in a new window.
  750. The value can be TRUE or FALSE (boolean):</p>
  751. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nx">auto_link</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="s1">&#39;both&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span>
  752. </pre></div>
  753. </div>
  754. </dd></dl>
  755. <dl class="function">
  756. <dt id="url_title">
  757. <code class="descname">url_title</code><span class="sig-paren">(</span><em>$str</em>, <em>$separator = '-'</em>, <em>$lowercase = FALSE</em><span class="sig-paren">)</span><a class="headerlink" href="#url_title" title="Permalink to this definition">¶</a></dt>
  758. <dd><table class="docutils field-list" frame="void" rules="none">
  759. <col class="field-name" />
  760. <col class="field-body" />
  761. <tbody valign="top">
  762. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  763. <li><strong>$str</strong> (<em>string</em>) – Input string</li>
  764. <li><strong>$separator</strong> (<em>string</em>) – Word separator</li>
  765. <li><strong>$lowercase</strong> (<em>bool</em>) – Whether to transform the output string to lower-case</li>
  766. </ul>
  767. </td>
  768. </tr>
  769. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">URL-formatted string</p>
  770. </td>
  771. </tr>
  772. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  773. </td>
  774. </tr>
  775. </tbody>
  776. </table>
  777. <p>Takes a string as input and creates a human-friendly URL string. This is
  778. useful if, for example, you have a blog in which you’d like to use the
  779. title of your entries in the URL. Example:</p>
  780. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$title</span> <span class="o">=</span> <span class="s2">&quot;What&#39;s wrong with CSS?&quot;</span><span class="p">;</span>
  781. <span class="nv">$url_title</span> <span class="o">=</span> <span class="nx">url_title</span><span class="p">(</span><span class="nv">$title</span><span class="p">);</span>
  782. <span class="c1">// Produces: Whats-wrong-with-CSS</span>
  783. </pre></div>
  784. </div>
  785. <p>The second parameter determines the word delimiter. By default dashes
  786. are used. Preferred options are: <strong>-</strong> (dash) or <strong>_</strong> (underscore)</p>
  787. <p>Example:</p>
  788. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$title</span> <span class="o">=</span> <span class="s2">&quot;What&#39;s wrong with CSS?&quot;</span><span class="p">;</span>
  789. <span class="nv">$url_title</span> <span class="o">=</span> <span class="nx">url_title</span><span class="p">(</span><span class="nv">$title</span><span class="p">,</span> <span class="s1">&#39;underscore&#39;</span><span class="p">);</span>
  790. <span class="c1">// Produces: Whats_wrong_with_CSS</span>
  791. </pre></div>
  792. </div>
  793. <div class="admonition note">
  794. <p class="first admonition-title">Note</p>
  795. <p class="last">Old usage of ‘dash’ and ‘underscore’ as the second parameter
  796. is DEPRECATED.</p>
  797. </div>
  798. <p>The third parameter determines whether or not lowercase characters are
  799. forced. By default they are not. Options are boolean TRUE/FALSE.</p>
  800. <p>Example:</p>
  801. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$title</span> <span class="o">=</span> <span class="s2">&quot;What&#39;s wrong with CSS?&quot;</span><span class="p">;</span>
  802. <span class="nv">$url_title</span> <span class="o">=</span> <span class="nx">url_title</span><span class="p">(</span><span class="nv">$title</span><span class="p">,</span> <span class="s1">&#39;underscore&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span>
  803. <span class="c1">// Produces: whats_wrong_with_css</span>
  804. </pre></div>
  805. </div>
  806. </dd></dl>
  807. <dl class="function">
  808. <dt id="prep_url">
  809. <code class="descname">prep_url</code><span class="sig-paren">(</span><em>$str = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#prep_url" title="Permalink to this definition">¶</a></dt>
  810. <dd><table class="docutils field-list" frame="void" rules="none">
  811. <col class="field-name" />
  812. <col class="field-body" />
  813. <tbody valign="top">
  814. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  815. <li><strong>$str</strong> (<em>string</em>) – URL string</li>
  816. </ul>
  817. </td>
  818. </tr>
  819. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Protocol-prefixed URL string</p>
  820. </td>
  821. </tr>
  822. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
  823. </td>
  824. </tr>
  825. </tbody>
  826. </table>
  827. <p>This function will add http:// in the event that a protocol prefix
  828. is missing from a URL.</p>
  829. <p>Pass the URL string to the function like this:</p>
  830. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$url</span> <span class="o">=</span> <span class="nx">prep_url</span><span class="p">(</span><span class="s1">&#39;example.com&#39;</span><span class="p">);</span>
  831. </pre></div>
  832. </div>
  833. </dd></dl>
  834. <dl class="function">
  835. <dt id="redirect">
  836. <code class="descname">redirect</code><span class="sig-paren">(</span><em>$uri = ''</em>, <em>$method = 'auto'</em>, <em>$code = NULL</em><span class="sig-paren">)</span><a class="headerlink" href="#redirect" title="Permalink to this definition">¶</a></dt>
  837. <dd><table class="docutils field-list" frame="void" rules="none">
  838. <col class="field-name" />
  839. <col class="field-body" />
  840. <tbody valign="top">
  841. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  842. <li><strong>$uri</strong> (<em>string</em>) – URI string</li>
  843. <li><strong>$method</strong> (<em>string</em>) – Redirect method (‘auto’, ‘location’ or ‘refresh’)</li>
  844. <li><strong>$code</strong> (<em>string</em>) – HTTP Response code (usually 302 or 303)</li>
  845. </ul>
  846. </td>
  847. </tr>
  848. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  849. </td>
  850. </tr>
  851. </tbody>
  852. </table>
  853. <p>Does a “header redirect” to the URI specified. If you specify the full
  854. site URL that link will be built, but for local links simply providing
  855. the URI segments to the controller you want to direct to will create the
  856. link. The function will build the URL based on your config file values.</p>
  857. <p>The optional second parameter allows you to force a particular redirection
  858. method. The available methods are <strong>auto</strong>, <strong>location</strong> and <strong>refresh</strong>,
  859. with location being faster but less reliable on IIS servers.
  860. The default is <strong>auto</strong>, which will attempt to intelligently choose the
  861. method based on the server environment.</p>
  862. <p>The optional third parameter allows you to send a specific HTTP Response
  863. Code - this could be used for example to create 301 redirects for search
  864. engine purposes. The default Response Code is 302. The third parameter is
  865. <em>only</em> available with <strong>location</strong> redirects, and not <em>refresh</em>. Examples:</p>
  866. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$logged_in</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span>
  867. <span class="p">{</span>
  868. <span class="nx">redirect</span><span class="p">(</span><span class="s1">&#39;/login/form/&#39;</span><span class="p">);</span>
  869. <span class="p">}</span>
  870. <span class="c1">// with 301 redirect</span>
  871. <span class="nx">redirect</span><span class="p">(</span><span class="s1">&#39;/article/13&#39;</span><span class="p">,</span> <span class="s1">&#39;location&#39;</span><span class="p">,</span> <span class="mi">301</span><span class="p">);</span>
  872. </pre></div>
  873. </div>
  874. <div class="admonition note">
  875. <p class="first admonition-title">Note</p>
  876. <p class="last">In order for this function to work it must be used before anything
  877. is outputted to the browser since it utilizes server headers.</p>
  878. </div>
  879. <div class="admonition note">
  880. <p class="first admonition-title">Note</p>
  881. <p class="last">For very fine grained control over headers, you should use the
  882. <a class="reference internal" href="../libraries/output.html"><span class="doc">Output Library</span></a> <code class="docutils literal"><span class="pre">set_header()</span></code> method.</p>
  883. </div>
  884. <div class="admonition note">
  885. <p class="first admonition-title">Note</p>
  886. <p class="last">To IIS users: if you hide the <cite>Server</cite> HTTP header, the <em>auto</em>
  887. method won’t detect IIS, in that case it is advised you explicitly
  888. use the <strong>refresh</strong> method.</p>
  889. </div>
  890. <div class="admonition note">
  891. <p class="first admonition-title">Note</p>
  892. <p class="last">When the <strong>location</strong> method is used, an HTTP status code of 303
  893. will <em>automatically</em> be selected when the page is currently accessed
  894. via POST and HTTP/1.1 is used.</p>
  895. </div>
  896. <div class="admonition important">
  897. <p class="first admonition-title">Important</p>
  898. <p class="last">This function will terminate script execution.</p>
  899. </div>
  900. </dd></dl>
  901. </div>
  902. </div>
  903. </div>
  904. <footer>
  905. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  906. <a href="xml_helper.html" class="btn btn-neutral float-right" title="XML Helper">Next <span class="fa fa-arrow-circle-right"></span></a>
  907. <a href="typography_helper.html" class="btn btn-neutral" title="Typography Helper"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  908. </div>
  909. <hr/>
  910. <div role="contentinfo">
  911. <p>
  912. &copy; Copyright 2014 - 2019, British Columbia Institute of Technology.
  913. Last updated on Sep 19, 2019.
  914. </p>
  915. </div>
  916. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  917. </footer>
  918. </div>
  919. </div>
  920. </section>
  921. </div>
  922. <script type="text/javascript">
  923. var DOCUMENTATION_OPTIONS = {
  924. URL_ROOT:'../',
  925. VERSION:'3.1.11',
  926. COLLAPSE_INDEX:false,
  927. FILE_SUFFIX:'.html',
  928. HAS_SOURCE: false
  929. };
  930. </script>
  931. <script type="text/javascript" src="../_static/jquery.js"></script>
  932. <script type="text/javascript" src="../_static/underscore.js"></script>
  933. <script type="text/javascript" src="../_static/doctools.js"></script>
  934. <script type="text/javascript" src="../_static/js/theme.js"></script>
  935. <script type="text/javascript">
  936. jQuery(function () {
  937. SphinxRtdTheme.StickyNav.enable();
  938. });
  939. </script>
  940. </body>
  941. </html>