diff options
author | Andrey Andreev <narf@devilix.net> | 2019-09-19 14:08:45 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2019-09-19 14:08:45 +0200 |
commit | b73eb19aed66190c10c9cad476da7c36c271d6dc (patch) | |
tree | b3d5d4f960569c30701934416d6d51628bde81a7 /user_guide/libraries | |
parent | 6e052d80b95b9332ed592cdc3431b5f9dc8dd250 (diff) |
[ci skip] 3.1.11 release
Diffstat (limited to 'user_guide/libraries')
31 files changed, 30765 insertions, 0 deletions
diff --git a/user_guide/libraries/benchmark.html b/user_guide/libraries/benchmark.html new file mode 100644 index 000000000..eeefb8c01 --- /dev/null +++ b/user_guide/libraries/benchmark.html @@ -0,0 +1,703 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Benchmarking Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Caching Driver" href="caching.html"/> + <link rel="prev" title="Libraries" href="index.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Benchmarking Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="benchmarking-class"> +<h1>Benchmarking Class<a class="headerlink" href="#benchmarking-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter has a Benchmarking class that is always active, enabling the +time difference between any two marked points to be calculated.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This class is initialized automatically by the system so there +is no need to do it manually.</p> +</div> +<p>In addition, the benchmark is always started the moment the framework is +invoked, and ended by the output class right before sending the final +view to the browser, enabling a very accurate timing of the entire +system execution to be shown.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-benchmark-class" id="id1">Using the Benchmark Class</a><ul> +<li><a class="reference internal" href="#profiling-your-benchmark-points" id="id2">Profiling Your Benchmark Points</a></li> +<li><a class="reference internal" href="#displaying-total-execution-time" id="id3">Displaying Total Execution Time</a></li> +<li><a class="reference internal" href="#displaying-memory-consumption" id="id4">Displaying Memory Consumption</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id5">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-benchmark-class"> +<h2><a class="toc-backref" href="#id1">Using the Benchmark Class</a><a class="headerlink" href="#using-the-benchmark-class" title="Permalink to this headline">¶</a></h2> +<p>The Benchmark class can be used within your +<a class="reference internal" href="../general/controllers.html"><span class="doc">controllers</span></a>, +<a class="reference internal" href="../general/views.html"><span class="doc">views</span></a>, or your <a class="reference internal" href="../general/models.html"><span class="doc">models</span></a>. +The process for usage is this:</p> +<ol class="arabic simple"> +<li>Mark a start point</li> +<li>Mark an end point</li> +<li>Run the “elapsed time” function to view the results</li> +</ol> +<p>Here’s an example using real code:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'code_start'</span><span class="p">);</span> + +<span class="c1">// Some code happens here</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'code_end'</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">elapsed_time</span><span class="p">(</span><span class="s1">'code_start'</span><span class="p">,</span> <span class="s1">'code_end'</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p>The words “code_start” and “code_end” are arbitrary. They +are simply words used to set two markers. You can use any words you +want, and you can set multiple sets of markers. Consider this example:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'dog'</span><span class="p">);</span> + +<span class="c1">// Some code happens here</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'cat'</span><span class="p">);</span> + +<span class="c1">// More code happens here</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'bird'</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">elapsed_time</span><span class="p">(</span><span class="s1">'dog'</span><span class="p">,</span> <span class="s1">'cat'</span><span class="p">);</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">elapsed_time</span><span class="p">(</span><span class="s1">'cat'</span><span class="p">,</span> <span class="s1">'bird'</span><span class="p">);</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">elapsed_time</span><span class="p">(</span><span class="s1">'dog'</span><span class="p">,</span> <span class="s1">'bird'</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="profiling-your-benchmark-points"> +<h3><a class="toc-backref" href="#id2">Profiling Your Benchmark Points</a><a class="headerlink" href="#profiling-your-benchmark-points" title="Permalink to this headline">¶</a></h3> +<p>If you want your benchmark data to be available to the +<a class="reference internal" href="../general/profiling.html"><span class="doc">Profiler</span></a> all of your marked points must +be set up in pairs, and each mark point name must end with _start and +_end. Each pair of points must otherwise be named identically. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'my_mark_start'</span><span class="p">);</span> + +<span class="c1">// Some code happens here...</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'my_mark_end'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'another_mark_start'</span><span class="p">);</span> + +<span class="c1">// Some more code happens here...</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">mark</span><span class="p">(</span><span class="s1">'another_mark_end'</span><span class="p">);</span> +</pre></div> +</div> +<p>Please read the <a class="reference internal" href="../general/profiling.html"><span class="doc">Profiler page</span></a> for more +information.</p> +</div> +<div class="section" id="displaying-total-execution-time"> +<h3><a class="toc-backref" href="#id3">Displaying Total Execution Time</a><a class="headerlink" href="#displaying-total-execution-time" title="Permalink to this headline">¶</a></h3> +<p>If you would like to display the total elapsed time from the moment +CodeIgniter starts to the moment the final output is sent to the +browser, simply place this in one of your view templates:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">elapsed_time</span><span class="p">();</span><span class="cp">?></span> +</pre></div> +</div> +<p>You’ll notice that it’s the same function used in the examples above to +calculate the time between two point, except you are <strong>not</strong> using any +parameters. When the parameters are absent, CodeIgniter does not stop +the benchmark until right before the final output is sent to the +browser. It doesn’t matter where you use the function call, the timer +will continue to run until the very end.</p> +<p>An alternate way to show your elapsed time in your view files is to use +this pseudo-variable, if you prefer not to use the pure PHP:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="p">{</span><span class="nx">elapsed_time</span><span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If you want to benchmark anything within your controller +functions you must set your own start/end points.</p> +</div> +</div> +<div class="section" id="displaying-memory-consumption"> +<h3><a class="toc-backref" href="#id4">Displaying Memory Consumption</a><a class="headerlink" href="#displaying-memory-consumption" title="Permalink to this headline">¶</a></h3> +<p>If your PHP installation is configured with –enable-memory-limit, you +can display the amount of memory consumed by the entire system using the +following code in one of your view file:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">benchmark</span><span class="o">-></span><span class="na">memory_usage</span><span class="p">();</span><span class="cp">?></span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This function can only be used in your view files. The consumption +will reflect the total memory used by the entire app.</p> +</div> +<p>An alternate way to show your memory usage in your view files is to use +this pseudo-variable, if you prefer not to use the pure PHP:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="p">{</span><span class="nx">memory_usage</span><span class="p">}</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id5">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Benchmark"> +<em class="property">class </em><code class="descname">CI_Benchmark</code><a class="headerlink" href="#CI_Benchmark" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Benchmark::mark"> +<code class="descname">mark</code><span class="sig-paren">(</span><em>$name</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Benchmark::mark" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$name</strong> (<em>string</em>) – the name you wish to assign to your marker</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets a benchmark marker.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Benchmark::elapsed_time"> +<code class="descname">elapsed_time</code><span class="sig-paren">(</span><span class="optional">[</span><em>$point1 = ''</em><span class="optional">[</span>, <em>$point2 = ''</em><span class="optional">[</span>, <em>$decimals = 4</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Benchmark::elapsed_time" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$point1</strong> (<em>string</em>) – a particular marked point</li> +<li><strong>$point2</strong> (<em>string</em>) – a particular marked point</li> +<li><strong>$decimals</strong> (<em>int</em>) – number of decimal places for precision</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Elapsed time</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Calculates and returns the time difference between two marked points.</p> +<p>If the first parameter is empty this function instead returns the +<code class="docutils literal"><span class="pre">{elapsed_time}</span></code> pseudo-variable. This permits the full system +execution time to be shown in a template. The output class will +swap the real value for this variable.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Benchmark::memory_usage"> +<code class="descname">memory_usage</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Benchmark::memory_usage" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Memory usage info</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Simply returns the <code class="docutils literal"><span class="pre">{memory_usage}</span></code> marker.</p> +<p>This permits it to be put it anywhere in a template without the memory +being calculated until the end. The <a class="reference internal" href="output.html"><span class="doc">Output Class</span></a> will +swap the real value for this variable.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="caching.html" class="btn btn-neutral float-right" title="Caching Driver">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="index.html" class="btn btn-neutral" title="Libraries"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/caching.html b/user_guide/libraries/caching.html new file mode 100644 index 000000000..0050cfe3a --- /dev/null +++ b/user_guide/libraries/caching.html @@ -0,0 +1,895 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Caching Driver — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Calendaring Class" href="calendar.html"/> + <link rel="prev" title="Benchmarking Class" href="benchmark.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Caching Driver</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="caching-driver"> +<h1>Caching Driver<a class="headerlink" href="#caching-driver" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter features wrappers around some of the most popular forms of +fast and dynamic caching. All but file-based caching require specific +server requirements, and a Fatal Exception will be thrown if server +requirements are not met.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#example-usage" id="id1">Example Usage</a></li> +<li><a class="reference internal" href="#class-reference" id="id2">Class Reference</a></li> +<li><a class="reference internal" href="#drivers" id="id3">Drivers</a><ul> +<li><a class="reference internal" href="#alternative-php-cache-apc-caching" id="id4">Alternative PHP Cache (APC) Caching</a></li> +<li><a class="reference internal" href="#file-based-caching" id="id5">File-based Caching</a></li> +<li><a class="reference internal" href="#memcached-caching" id="id6">Memcached Caching</a></li> +<li><a class="reference internal" href="#wincache-caching" id="id7">WinCache Caching</a></li> +<li><a class="reference internal" href="#redis-caching" id="id8">Redis Caching</a></li> +<li><a class="reference internal" href="#dummy-cache" id="id9">Dummy Cache</a></li> +</ul> +</li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="example-usage"> +<h2><a class="toc-backref" href="#id1">Example Usage</a><a class="headerlink" href="#example-usage" title="Permalink to this headline">¶</a></h2> +<p>The following example will load the cache driver, specify <a class="reference external" href="#alternative-php-cache-apc-caching">APC</a> +as the driver to use, and fall back to file-based caching if APC is not +available in the hosting environment.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">'adapter'</span> <span class="o">=></span> <span class="s1">'apc'</span><span class="p">,</span> <span class="s1">'backup'</span> <span class="o">=></span> <span class="s1">'file'</span><span class="p">));</span> + +<span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$foo</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">))</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'Saving to the cache!<br />'</span><span class="p">;</span> + <span class="nv">$foo</span> <span class="o">=</span> <span class="s1">'foobarbaz!'</span><span class="p">;</span> + + <span class="c1">// Save into the cache for 5 minutes</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="nv">$foo</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> +<span class="p">}</span> + +<span class="k">echo</span> <span class="nv">$foo</span><span class="p">;</span> +</pre></div> +</div> +<p>You can also prefix cache item names via the <strong>key_prefix</strong> setting, which is useful +to avoid collisions when you’re running multiple applications on the same environment.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'adapter'</span> <span class="o">=></span> <span class="s1">'apc'</span><span class="p">,</span> <span class="s1">'backup'</span> <span class="o">=></span> <span class="s1">'file'</span><span class="p">,</span> <span class="s1">'key_prefix'</span> <span class="o">=></span> <span class="s1">'my_'</span><span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">);</span> <span class="c1">// Will get the cache entry named 'my_foo'</span> +</pre></div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id2">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Cache"> +<em class="property">class </em><code class="descname">CI_Cache</code><a class="headerlink" href="#CI_Cache" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Cache::is_supported"> +<code class="descname">is_supported</code><span class="sig-paren">(</span><em>$driver</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::is_supported" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$driver</strong> (<em>string</em>) – the name of the caching driver</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if supported, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>This method is automatically called when accessing drivers via +<code class="docutils literal"><span class="pre">$this->cache->get()</span></code>. However, if the individual drivers are used, +make sure to call this method to ensure the driver is supported in the +hosting environment.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">apc</span><span class="o">-></span><span class="na">is_supported</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">if</span> <span class="p">(</span><span class="nv">$data</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">apc</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'my_cache'</span><span class="p">))</span> + <span class="p">{</span> + <span class="c1">// do things.</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::get"> +<code class="descname">get</code><span class="sig-paren">(</span><em>$id</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::get" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$id</strong> (<em>string</em>) – Cache item name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Item value or FALSE if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method will attempt to fetch an item from the cache store. If the +item does not exist, the method will return FALSE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$foo</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'my_cached_item'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::save"> +<code class="descname">save</code><span class="sig-paren">(</span><em>$id</em>, <em>$data</em><span class="optional">[</span>, <em>$ttl = 60</em><span class="optional">[</span>, <em>$raw = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::save" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$id</strong> (<em>string</em>) – Cache item name</li> +<li><strong>$data</strong> (<em>mixed</em>) – the data to save</li> +<li><strong>$ttl</strong> (<em>int</em>) – Time To Live, in seconds (default 60)</li> +<li><strong>$raw</strong> (<em>bool</em>) – Whether to store the raw value</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>This method will save an item to the cache store. If saving fails, the +method will return FALSE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'cache_item_id'</span><span class="p">,</span> <span class="s1">'data_to_cache'</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The <code class="docutils literal"><span class="pre">$raw</span></code> parameter is only utilized by APC and Memcache, +in order to allow usage of <code class="docutils literal"><span class="pre">increment()</span></code> and <code class="docutils literal"><span class="pre">decrement()</span></code>.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::delete"> +<code class="descname">delete</code><span class="sig-paren">(</span><em>$id</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::delete" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$id</strong> (<em>string</em>) – name of cached item</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>This method will delete a specific item from the cache store. If item +deletion fails, the method will return FALSE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">delete</span><span class="p">(</span><span class="s1">'cache_item_id'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::increment"> +<code class="descname">increment</code><span class="sig-paren">(</span><em>$id</em><span class="optional">[</span>, <em>$offset = 1</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::increment" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$id</strong> (<em>string</em>) – Cache ID</li> +<li><strong>$offset</strong> (<em>int</em>) – Step/value to add</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">New value on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Performs atomic incrementation of a raw stored value.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// 'iterator' has a value of 2</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">increment</span><span class="p">(</span><span class="s1">'iterator'</span><span class="p">);</span> <span class="c1">// 'iterator' is now 3</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">increment</span><span class="p">(</span><span class="s1">'iterator'</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span> <span class="c1">// 'iterator' is now 6</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::decrement"> +<code class="descname">decrement</code><span class="sig-paren">(</span><em>$id</em><span class="optional">[</span>, <em>$offset = 1</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::decrement" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$id</strong> (<em>string</em>) – Cache ID</li> +<li><strong>$offset</strong> (<em>int</em>) – Step/value to reduce by</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">New value on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Performs atomic decrementation of a raw stored value.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// 'iterator' has a value of 6</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">decrement</span><span class="p">(</span><span class="s1">'iterator'</span><span class="p">);</span> <span class="c1">// 'iterator' is now 5</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">decrement</span><span class="p">(</span><span class="s1">'iterator'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> <span class="c1">// 'iterator' is now 3</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::clean"> +<code class="descname">clean</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::clean" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>This method will ‘clean’ the entire cache. If the deletion of the +cache files fails, the method will return FALSE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">clean</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::cache_info"> +<code class="descname">cache_info</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::cache_info" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Information on the entire cache database</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td> +</tr> +</tbody> +</table> +<p>This method will return information on the entire cache.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">var_dump</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">cache_info</span><span class="p">());</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The information returned and the structure of the data is dependent +on which adapter is being used.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cache::get_metadata"> +<code class="descname">get_metadata</code><span class="sig-paren">(</span><em>$id</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cache::get_metadata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$id</strong> (<em>string</em>) – Cache item name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Metadata for the cached item</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method will return detailed information on a specific item in the +cache.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">var_dump</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">get_metadata</span><span class="p">(</span><span class="s1">'my_cached_item'</span><span class="p">));</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The information returned and the structure of the data is dependent +on which adapter is being used.</p> +</div> +</dd></dl> + +</dd></dl> + +</div> +<div class="section" id="drivers"> +<h2><a class="toc-backref" href="#id3">Drivers</a><a class="headerlink" href="#drivers" title="Permalink to this headline">¶</a></h2> +<div class="section" id="alternative-php-cache-apc-caching"> +<h3><a class="toc-backref" href="#id4">Alternative PHP Cache (APC) Caching</a><a class="headerlink" href="#alternative-php-cache-apc-caching" title="Permalink to this headline">¶</a></h3> +<p>All of the methods listed above can be accessed without passing a +specific adapter to the driver loader as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">apc</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> +</pre></div> +</div> +<p>For more information on APC, please see +<a class="reference external" href="http://php.net/apc">http://php.net/apc</a>.</p> +</div> +<div class="section" id="file-based-caching"> +<h3><a class="toc-backref" href="#id5">File-based Caching</a><a class="headerlink" href="#file-based-caching" title="Permalink to this headline">¶</a></h3> +<p>Unlike caching from the Output Class, the driver file-based caching +allows for pieces of view files to be cached. Use this with care, and +make sure to benchmark your application, as a point can come where disk +I/O will negate positive gains by caching.</p> +<p>All of the methods listed above can be accessed without passing a +specific adapter to the driver loader as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">file</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="memcached-caching"> +<h3><a class="toc-backref" href="#id6">Memcached Caching</a><a class="headerlink" href="#memcached-caching" title="Permalink to this headline">¶</a></h3> +<p>Multiple Memcached servers can be specified in the memcached.php +configuration file, located in the _application/config/* directory.</p> +<p>All of the methods listed above can be accessed without passing a +specific adapter to the driver loader as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">memcached</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> +</pre></div> +</div> +<p>For more information on Memcached, please see +<a class="reference external" href="http://php.net/memcached">http://php.net/memcached</a>.</p> +</div> +<div class="section" id="wincache-caching"> +<h3><a class="toc-backref" href="#id7">WinCache Caching</a><a class="headerlink" href="#wincache-caching" title="Permalink to this headline">¶</a></h3> +<p>Under Windows, you can also utilize the WinCache driver.</p> +<p>All of the methods listed above can be accessed without passing a +specific adapter to the driver loader as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">wincache</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> +</pre></div> +</div> +<p>For more information on WinCache, please see +<a class="reference external" href="http://php.net/wincache">http://php.net/wincache</a>.</p> +</div> +<div class="section" id="redis-caching"> +<h3><a class="toc-backref" href="#id8">Redis Caching</a><a class="headerlink" href="#redis-caching" title="Permalink to this headline">¶</a></h3> +<p>Redis is an in-memory key-value store which can operate in LRU cache mode. +To use it, you need <a class="reference external" href="https://github.com/phpredis/phpredis">Redis server and phpredis PHP extension</a>.</p> +<p>Config options to connect to redis server must be stored in the application/config/redis.php file. +Available options are:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'socket_type'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'tcp'</span><span class="p">;</span> <span class="c1">//`tcp` or `unix`</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'socket'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/var/run/redis.sock'</span><span class="p">;</span> <span class="c1">// in case of `unix` socket type</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'host'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'127.0.0.1'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'password'</span><span class="p">]</span> <span class="o">=</span> <span class="k">NULL</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'port'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">6379</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'timeout'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> +</pre></div> +</div> +<p>All of the methods listed above can be accessed without passing a +specific adapter to the driver loader as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'cache'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">cache</span><span class="o">-></span><span class="na">redis</span><span class="o">-></span><span class="na">save</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> +</pre></div> +</div> +<p>For more information on Redis, please see +<a class="reference external" href="http://redis.io">http://redis.io</a>.</p> +</div> +<div class="section" id="dummy-cache"> +<h3><a class="toc-backref" href="#id9">Dummy Cache</a><a class="headerlink" href="#dummy-cache" title="Permalink to this headline">¶</a></h3> +<p>This is a caching backend that will always ‘miss.’ It stores no data, +but lets you keep your caching code in place in environments that don’t +support your chosen cache.</p> +</div> +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="calendar.html" class="btn btn-neutral float-right" title="Calendaring Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="benchmark.html" class="btn btn-neutral" title="Benchmarking Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/calendar.html b/user_guide/libraries/calendar.html new file mode 100644 index 000000000..0ca359288 --- /dev/null +++ b/user_guide/libraries/calendar.html @@ -0,0 +1,972 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Calendaring Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Shopping Cart Class" href="cart.html"/> + <link rel="prev" title="Caching Driver" href="caching.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Calendaring Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="calendaring-class"> +<h1>Calendaring Class<a class="headerlink" href="#calendaring-class" title="Permalink to this headline">¶</a></h1> +<p>The Calendar class enables you to dynamically create calendars. Your +calendars can be formatted through the use of a calendar template, +allowing 100% control over every aspect of its design. In addition, you +can pass data to your calendar cells.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-calendaring-class" id="id1">Using the Calendaring Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#displaying-a-calendar" id="id3">Displaying a Calendar</a></li> +<li><a class="reference internal" href="#passing-data-to-your-calendar-cells" id="id4">Passing Data to your Calendar Cells</a></li> +<li><a class="reference internal" href="#setting-display-preferences" id="id5">Setting Display Preferences</a></li> +<li><a class="reference internal" href="#showing-next-previous-month-links" id="id6">Showing Next/Previous Month Links</a></li> +<li><a class="reference internal" href="#creating-a-calendar-template" id="id7">Creating a Calendar Template</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id8">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-calendaring-class"> +<h2><a class="toc-backref" href="#id1">Using the Calendaring Class</a><a class="headerlink" href="#using-the-calendaring-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Calendar class is +initialized in your controller using the $this->load->library function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Calendar object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span> +</pre></div> +</div> +</div> +<div class="section" id="displaying-a-calendar"> +<h3><a class="toc-backref" href="#id3">Displaying a Calendar</a><a class="headerlink" href="#displaying-a-calendar" title="Permalink to this headline">¶</a></h3> +<p>Here is a very simple example showing how you can display a calendar:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">);</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +<p>The above code will generate a calendar for the current month/year based +on your server time. To show a calendar for a specific month and year +you will pass this information to the calendar generating function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">);</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">(</span><span class="mi">2006</span><span class="p">,</span> <span class="mi">6</span><span class="p">);</span> +</pre></div> +</div> +<p>The above code will generate a calendar showing the month of June in +2006. The first parameter specifies the year, the second parameter +specifies the month.</p> +</div> +<div class="section" id="passing-data-to-your-calendar-cells"> +<h3><a class="toc-backref" href="#id4">Passing Data to your Calendar Cells</a><a class="headerlink" href="#passing-data-to-your-calendar-cells" title="Permalink to this headline">¶</a></h3> +<p>To add data to your calendar cells involves creating an associative +array in which the keys correspond to the days you wish to populate and +the array value contains the data. The array is passed to the third +parameter of the calendar generating function. Consider this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">);</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="mi">3</span> <span class="o">=></span> <span class="s1">'http://example.com/news/article/2006/06/03/'</span><span class="p">,</span> + <span class="mi">7</span> <span class="o">=></span> <span class="s1">'http://example.com/news/article/2006/06/07/'</span><span class="p">,</span> + <span class="mi">13</span> <span class="o">=></span> <span class="s1">'http://example.com/news/article/2006/06/13/'</span><span class="p">,</span> + <span class="mi">26</span> <span class="o">=></span> <span class="s1">'http://example.com/news/article/2006/06/26/'</span> +<span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">(</span><span class="mi">2006</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>Using the above example, day numbers 3, 7, 13, and 26 will become links +pointing to the URLs you’ve provided.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">By default it is assumed that your array will contain links. +In the section that explains the calendar template below you’ll see how +you can customize how data passed to your cells is handled so you can +pass different types of information.</p> +</div> +</div> +<div class="section" id="setting-display-preferences"> +<h3><a class="toc-backref" href="#id5">Setting Display Preferences</a><a class="headerlink" href="#setting-display-preferences" title="Permalink to this headline">¶</a></h3> +<p>There are seven preferences you can set to control various aspects of +the calendar. Preferences are set by passing an array of preferences in +the second parameter of the loading function. Here is an example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$prefs</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'start_day'</span> <span class="o">=></span> <span class="s1">'saturday'</span><span class="p">,</span> + <span class="s1">'month_type'</span> <span class="o">=></span> <span class="s1">'long'</span><span class="p">,</span> + <span class="s1">'day_type'</span> <span class="o">=></span> <span class="s1">'short'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">,</span> <span class="nv">$prefs</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +<p>The above code would start the calendar on saturday, use the “long” +month heading, and the “short” day names. More information regarding +preferences below.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="15%" /> +<col width="11%" /> +<col width="29%" /> +<col width="45%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>template</strong></td> +<td>None</td> +<td>None</td> +<td><dl class="first last docutils"> +<dt>A string or array containing your calendar template.</dt> +<dd>See the template section below.</dd> +</dl> +</td> +</tr> +<tr class="row-odd"><td><strong>local_time</strong></td> +<td>time()</td> +<td>None</td> +<td>A Unix timestamp corresponding to the current time.</td> +</tr> +<tr class="row-even"><td><strong>start_day</strong></td> +<td>sunday</td> +<td>Any week day (sunday, monday, tuesday, etc.)</td> +<td>Sets the day of the week the calendar should start on.</td> +</tr> +<tr class="row-odd"><td><strong>month_type</strong></td> +<td>long</td> +<td>long, short</td> +<td><dl class="first last docutils"> +<dt>Determines what version of the month name to use in the header.</dt> +<dd>long = January, short = Jan.</dd> +</dl> +</td> +</tr> +<tr class="row-even"><td><strong>day_type</strong></td> +<td>abr</td> +<td>long, short, abr</td> +<td><dl class="first last docutils"> +<dt>Determines what version of the weekday names to use in</dt> +<dd>the column headers. long = Sunday, short = Sun, abr = Su.</dd> +</dl> +</td> +</tr> +<tr class="row-odd"><td><strong>show_next_prev</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td><dl class="first last docutils"> +<dt>Determines whether to display links allowing you to toggle</dt> +<dd>to next/previous months. See information on this feature below.</dd> +</dl> +</td> +</tr> +<tr class="row-even"><td><strong>next_prev_url</strong></td> +<td>controller/method</td> +<td>A URL</td> +<td>Sets the basepath used in the next/previous calendar links.</td> +</tr> +<tr class="row-odd"><td><strong>show_other_days</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td><dl class="first last docutils"> +<dt>Determines whether to display days of other months that share the</dt> +<dd>first or last week of the calendar month.</dd> +</dl> +</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="showing-next-previous-month-links"> +<h3><a class="toc-backref" href="#id6">Showing Next/Previous Month Links</a><a class="headerlink" href="#showing-next-previous-month-links" title="Permalink to this headline">¶</a></h3> +<p>To allow your calendar to dynamically increment/decrement via the +next/previous links requires that you set up your calendar code similar +to this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$prefs</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'show_next_prev'</span> <span class="o">=></span> <span class="k">TRUE</span><span class="p">,</span> + <span class="s1">'next_prev_url'</span> <span class="o">=></span> <span class="s1">'http://example.com/index.php/calendar/show/'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">,</span> <span class="nv">$prefs</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">4</span><span class="p">));</span> +</pre></div> +</div> +<p>You’ll notice a few things about the above example:</p> +<ul class="simple"> +<li>You must set the “show_next_prev” to TRUE.</li> +<li>You must supply the URL to the controller containing your calendar in +the “next_prev_url” preference. If you don’t, it will be set to the current +<em>controller/method</em>.</li> +<li>You must supply the “year” and “month” to the calendar generating +function via the URI segments where they appear (Note: The calendar +class automatically adds the year/month to the base URL you +provide.).</li> +</ul> +</div> +<div class="section" id="creating-a-calendar-template"> +<h3><a class="toc-backref" href="#id7">Creating a Calendar Template</a><a class="headerlink" href="#creating-a-calendar-template" title="Permalink to this headline">¶</a></h3> +<p>By creating a calendar template you have 100% control over the design of +your calendar. Using the string method, each component of your calendar +will be placed within a pair of pseudo-variables as shown here:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$prefs</span><span class="p">[</span><span class="s1">'template'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'</span> + +<span class="s1"> {table_open}<table border="0" cellpadding="0" cellspacing="0">{/table_open}</span> + +<span class="s1"> {heading_row_start}<tr>{/heading_row_start}</span> + +<span class="s1"> {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}</span> +<span class="s1"> {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}</span> +<span class="s1"> {heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}</span> + +<span class="s1"> {heading_row_end}</tr>{/heading_row_end}</span> + +<span class="s1"> {week_row_start}<tr>{/week_row_start}</span> +<span class="s1"> {week_day_cell}<td>{week_day}</td>{/week_day_cell}</span> +<span class="s1"> {week_row_end}</tr>{/week_row_end}</span> + +<span class="s1"> {cal_row_start}<tr>{/cal_row_start}</span> +<span class="s1"> {cal_cell_start}<td>{/cal_cell_start}</span> +<span class="s1"> {cal_cell_start_today}<td>{/cal_cell_start_today}</span> +<span class="s1"> {cal_cell_start_other}<td class="other-month">{/cal_cell_start_other}</span> + +<span class="s1"> {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content}</span> +<span class="s1"> {cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/cal_cell_content_today}</span> + +<span class="s1"> {cal_cell_no_content}{day}{/cal_cell_no_content}</span> +<span class="s1"> {cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}</span> + +<span class="s1"> {cal_cell_blank}&nbsp;{/cal_cell_blank}</span> + +<span class="s1"> {cal_cell_other}{day}{/cal_cel_other}</span> + +<span class="s1"> {cal_cell_end}</td>{/cal_cell_end}</span> +<span class="s1"> {cal_cell_end_today}</td>{/cal_cell_end_today}</span> +<span class="s1"> {cal_cell_end_other}</td>{/cal_cell_end_other}</span> +<span class="s1"> {cal_row_end}</tr>{/cal_row_end}</span> + +<span class="s1"> {table_close}</table>{/table_close}</span> +<span class="s1">'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">,</span> <span class="nv">$prefs</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +<p>Using the array method, you will pass <cite>key => value</cite> pairs. You can pass as +many or as few values as you’d like. Omitted keys will use the default values +inherited in the calendar class.</p> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$prefs</span><span class="p">[</span><span class="s1">'template'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'table_open'</span> <span class="o">=></span> <span class="s1">'<table class="calendar">'</span><span class="p">,</span> + <span class="s1">'cal_cell_start'</span> <span class="o">=></span> <span class="s1">'<td class="day">'</span><span class="p">,</span> + <span class="s1">'cal_cell_start_today'</span> <span class="o">=></span> <span class="s1">'<td class="today">'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">,</span> <span class="nv">$prefs</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id8">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Calendar"> +<em class="property">class </em><code class="descname">CI_Calendar</code><a class="headerlink" href="#CI_Calendar" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Calendar::initialize"> +<code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>$config = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::initialize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$config</strong> (<em>array</em>) – Configuration parameters</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Calendar instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Calendar</p> +</td> +</tr> +</tbody> +</table> +<p>Initializes the Calendaring preferences. Accepts an associative array as input, containing display preferences.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::generate"> +<code class="descname">generate</code><span class="sig-paren">(</span><span class="optional">[</span><em>$year = ''</em><span class="optional">[</span>, <em>$month = ''</em><span class="optional">[</span>, <em>$data = array()</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::generate" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$year</strong> (<em>int</em>) – Year</li> +<li><strong>$month</strong> (<em>int</em>) – Month</li> +<li><strong>$data</strong> (<em>array</em>) – Data to be shown in the calendar cells</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML-formatted calendar</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Generate the calendar.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::get_month_name"> +<code class="descname">get_month_name</code><span class="sig-paren">(</span><em>$month</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::get_month_name" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$month</strong> (<em>int</em>) – Month</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Month name</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Generates a textual month name based on the numeric month provided.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::get_day_names"> +<code class="descname">get_day_names</code><span class="sig-paren">(</span><em>$day_type = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::get_day_names" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$day_type</strong> (<em>string</em>) – ‘long’, ‘short’, or ‘abr’</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of day names</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns an array of day names (Sunday, Monday, etc.) based on the type +provided. Options: long, short, abr. If no <code class="docutils literal"><span class="pre">$day_type</span></code> is provided (or +if an invalid type is provided) this method will return the “abbreviated” +style.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::adjust_date"> +<code class="descname">adjust_date</code><span class="sig-paren">(</span><em>$month</em>, <em>$year</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::adjust_date" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$month</strong> (<em>int</em>) – Month</li> +<li><strong>$year</strong> (<em>int</em>) – Year</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An associative array containing month and year</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>This method makes sure that you have a valid month/year. For example, if +you submit 13 as the month, the year will increment and the month will +become January:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">print_r</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">adjust_date</span><span class="p">(</span><span class="mi">13</span><span class="p">,</span> <span class="mi">2014</span><span class="p">));</span> +</pre></div> +</div> +<p>outputs:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">Array</span> +<span class="p">(</span> + <span class="p">[</span><span class="nx">month</span><span class="p">]</span> <span class="o">=></span> <span class="s1">'01'</span> + <span class="p">[</span><span class="nx">year</span><span class="p">]</span> <span class="o">=></span> <span class="s1">'2015'</span> +<span class="p">)</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::get_total_days"> +<code class="descname">get_total_days</code><span class="sig-paren">(</span><em>$month</em>, <em>$year</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::get_total_days" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$month</strong> (<em>int</em>) – Month</li> +<li><strong>$year</strong> (<em>int</em>) – Year</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Count of days in the specified month</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int</p> +</td> +</tr> +</tbody> +</table> +<p>Total days in a given month:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">calendar</span><span class="o">-></span><span class="na">get_total_days</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2012</span><span class="p">);</span> +<span class="c1">// 29</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is an alias for <a class="reference internal" href="../helpers/date_helper.html"><span class="doc">Date Helper</span></a> function <a class="reference internal" href="../helpers/date_helper.html#days_in_month" title="days_in_month"><code class="xref php php-func docutils literal"><span class="pre">days_in_month()</span></code></a>.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::default_template"> +<code class="descname">default_template</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::default_template" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array of template values</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Sets the default template. This method is used when you have not created +your own template.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Calendar::parse_template"> +<code class="descname">parse_template</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Calendar::parse_template" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">CI_Calendar instance (method chaining)</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">CI_Calendar</td> +</tr> +</tbody> +</table> +<p>Harvests the data within the template <code class="docutils literal"><span class="pre">{pseudo-variables}</span></code> used to +display the calendar.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="cart.html" class="btn btn-neutral float-right" title="Shopping Cart Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="caching.html" class="btn btn-neutral" title="Caching Driver"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html new file mode 100644 index 000000000..7b139efaf --- /dev/null +++ b/user_guide/libraries/cart.html @@ -0,0 +1,1025 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Shopping Cart Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Config Class" href="config.html"/> + <link rel="prev" title="Calendaring Class" href="calendar.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Shopping Cart Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="shopping-cart-class"> +<h1>Shopping Cart Class<a class="headerlink" href="#shopping-cart-class" title="Permalink to this headline">¶</a></h1> +<p>The Cart Class permits items to be added to a session that stays active +while a user is browsing your site. These items can be retrieved and +displayed in a standard “shopping cart” format, allowing the user to +update the quantity or remove items from the cart.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The Cart library is DEPRECATED and should not be used. +It is currently only kept for backwards compatibility.</p> +</div> +<p>Please note that the Cart Class ONLY provides the core “cart” +functionality. It does not provide shipping, credit card authorization, +or other processing components.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-cart-class" id="id1">Using the Cart Class</a><ul> +<li><a class="reference internal" href="#initializing-the-shopping-cart-class" id="id2">Initializing the Shopping Cart Class</a></li> +<li><a class="reference internal" href="#adding-an-item-to-the-cart" id="id3">Adding an Item to The Cart</a></li> +<li><a class="reference internal" href="#adding-multiple-items-to-the-cart" id="id4">Adding Multiple Items to The Cart</a></li> +<li><a class="reference internal" href="#displaying-the-cart" id="id5">Displaying the Cart</a></li> +<li><a class="reference internal" href="#updating-the-cart" id="id6">Updating The Cart</a><ul> +<li><a class="reference internal" href="#what-is-a-row-id" id="id7">What is a Row ID?</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id8">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-cart-class"> +<h2><a class="toc-backref" href="#id1">Using the Cart Class</a><a class="headerlink" href="#using-the-cart-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-shopping-cart-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Shopping Cart Class</a><a class="headerlink" href="#initializing-the-shopping-cart-class" title="Permalink to this headline">¶</a></h3> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The Cart class utilizes CodeIgniter’s <a class="reference internal" href="sessions.html"><span class="doc">Session +Class</span></a> to save the cart information to a database, so +before using the Cart class you must set up a database table as +indicated in the <a class="reference internal" href="sessions.html"><span class="doc">Session Documentation</span></a>, and set the +session preferences in your application/config/config.php file to +utilize a database.</p> +</div> +<p>To initialize the Shopping Cart Class in your controller constructor, +use the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'cart'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Cart object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">cart</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The Cart Class will load and initialize the Session Class +automatically, so unless you are using sessions elsewhere in your +application, you do not need to load the Session class.</p> +</div> +</div> +<div class="section" id="adding-an-item-to-the-cart"> +<h3><a class="toc-backref" href="#id3">Adding an Item to The Cart</a><a class="headerlink" href="#adding-an-item-to-the-cart" title="Permalink to this headline">¶</a></h3> +<p>To add an item to the shopping cart, simply pass an array with the +product information to the <code class="docutils literal"><span class="pre">$this->cart->insert()</span></code> method, as shown +below:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'id'</span> <span class="o">=></span> <span class="s1">'sku_123ABC'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> + <span class="s1">'price'</span> <span class="o">=></span> <span class="mf">39.95</span><span class="p">,</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'T-Shirt'</span><span class="p">,</span> + <span class="s1">'options'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'Size'</span> <span class="o">=></span> <span class="s1">'L'</span><span class="p">,</span> <span class="s1">'Color'</span> <span class="o">=></span> <span class="s1">'Red'</span><span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">insert</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The first four array indexes above (id, qty, price, and +name) are <strong>required</strong>. If you omit any of them the data will not be +saved to the cart. The fifth index (options) is optional. It is intended +to be used in cases where your product has options associated with it. +Use an array for options, as shown above.</p> +</div> +<p>The five reserved indexes are:</p> +<ul class="simple"> +<li><strong>id</strong> - Each product in your store must have a unique identifier. +Typically this will be an “sku” or other such identifier.</li> +<li><strong>qty</strong> - The quantity being purchased.</li> +<li><strong>price</strong> - The price of the item.</li> +<li><strong>name</strong> - The name of the item.</li> +<li><strong>options</strong> - Any additional attributes that are needed to identify +the product. These must be passed via an array.</li> +</ul> +<p>In addition to the five indexes above, there are two reserved words: +rowid and subtotal. These are used internally by the Cart class, so +please do NOT use those words as index names when inserting data into +the cart.</p> +<p>Your array may contain additional data. Anything you include in your +array will be stored in the session. However, it is best to standardize +your data among all your products in order to make displaying the +information in a table easier.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'id'</span> <span class="o">=></span> <span class="s1">'sku_123ABC'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> + <span class="s1">'price'</span> <span class="o">=></span> <span class="mf">39.95</span><span class="p">,</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'T-Shirt'</span><span class="p">,</span> + <span class="s1">'coupon'</span> <span class="o">=></span> <span class="s1">'XMAS-50OFF'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">insert</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>The <code class="docutils literal"><span class="pre">insert()</span></code> method will return the $rowid if you successfully insert a +single item.</p> +</div> +<div class="section" id="adding-multiple-items-to-the-cart"> +<h3><a class="toc-backref" href="#id4">Adding Multiple Items to The Cart</a><a class="headerlink" href="#adding-multiple-items-to-the-cart" title="Permalink to this headline">¶</a></h3> +<p>By using a multi-dimensional array, as shown below, it is possible to +add multiple products to the cart in one action. This is useful in cases +where you wish to allow people to select from among several items on the +same page.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'id'</span> <span class="o">=></span> <span class="s1">'sku_123ABC'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> + <span class="s1">'price'</span> <span class="o">=></span> <span class="mf">39.95</span><span class="p">,</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'T-Shirt'</span><span class="p">,</span> + <span class="s1">'options'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'Size'</span> <span class="o">=></span> <span class="s1">'L'</span><span class="p">,</span> <span class="s1">'Color'</span> <span class="o">=></span> <span class="s1">'Red'</span><span class="p">)</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'id'</span> <span class="o">=></span> <span class="s1">'sku_567ZYX'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> + <span class="s1">'price'</span> <span class="o">=></span> <span class="mf">9.95</span><span class="p">,</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'Coffee Mug'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'id'</span> <span class="o">=></span> <span class="s1">'sku_965QRS'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> + <span class="s1">'price'</span> <span class="o">=></span> <span class="mf">29.95</span><span class="p">,</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'Shot Glass'</span> + <span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">insert</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="displaying-the-cart"> +<h3><a class="toc-backref" href="#id5">Displaying the Cart</a><a class="headerlink" href="#displaying-the-cart" title="Permalink to this headline">¶</a></h3> +<p>To display the cart you will create a <a class="reference internal" href="../general/views.html"><span class="doc">view +file</span></a> with code similar to the one shown below.</p> +<p>Please note that this example uses the <a class="reference internal" href="../helpers/form_helper.html"><span class="doc">form +helper</span></a>.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">'path/to/controller/update/method'</span><span class="p">);</span> <span class="cp">?></span> + +<span class="p"><</span><span class="nt">table</span> <span class="na">cellpadding</span><span class="o">=</span><span class="s">"6"</span> <span class="na">cellspacing</span><span class="o">=</span><span class="s">"1"</span> <span class="na">style</span><span class="o">=</span><span class="s">"width:100%"</span> <span class="na">border</span><span class="o">=</span><span class="s">"0"</span><span class="p">></span> + +<span class="p"><</span><span class="nt">tr</span><span class="p">></span> + <span class="p"><</span><span class="nt">th</span><span class="p">></span>QTY<span class="p"></</span><span class="nt">th</span><span class="p">></span> + <span class="p"><</span><span class="nt">th</span><span class="p">></span>Item Description<span class="p"></</span><span class="nt">th</span><span class="p">></span> + <span class="p"><</span><span class="nt">th</span> <span class="na">style</span><span class="o">=</span><span class="s">"text-align:right"</span><span class="p">></span>Item Price<span class="p"></</span><span class="nt">th</span><span class="p">></span> + <span class="p"><</span><span class="nt">th</span> <span class="na">style</span><span class="o">=</span><span class="s">"text-align:right"</span><span class="p">></span>Sub-Total<span class="p"></</span><span class="nt">th</span><span class="p">></span> +<span class="p"></</span><span class="nt">tr</span><span class="p">></span> + +<span class="cp"><?php</span> <span class="nv">$i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="cp">?></span> + +<span class="cp"><?php</span> <span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">contents</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$items</span><span class="p">)</span><span class="o">:</span> <span class="cp">?></span> + + <span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_hidden</span><span class="p">(</span><span class="nv">$i</span><span class="o">.</span><span class="s1">'[rowid]'</span><span class="p">,</span> <span class="nv">$items</span><span class="p">[</span><span class="s1">'rowid'</span><span class="p">]);</span> <span class="cp">?></span> + + <span class="p"><</span><span class="nt">tr</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span><span class="p">></span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'name'</span> <span class="o">=></span> <span class="nv">$i</span><span class="o">.</span><span class="s1">'[qty]'</span><span class="p">,</span> <span class="s1">'value'</span> <span class="o">=></span> <span class="nv">$items</span><span class="p">[</span><span class="s1">'qty'</span><span class="p">],</span> <span class="s1">'maxlength'</span> <span class="o">=></span> <span class="s1">'3'</span><span class="p">,</span> <span class="s1">'size'</span> <span class="o">=></span> <span class="s1">'5'</span><span class="p">));</span> <span class="cp">?></span><span class="p"></</span><span class="nt">td</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span><span class="p">></span> + <span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$items</span><span class="p">[</span><span class="s1">'name'</span><span class="p">];</span> <span class="cp">?></span> + + <span class="cp"><?php</span> <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">has_options</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">'rowid'</span><span class="p">])</span> <span class="o">==</span> <span class="k">TRUE</span><span class="p">)</span><span class="o">:</span> <span class="cp">?></span> + + <span class="p"><</span><span class="nt">p</span><span class="p">></span> + <span class="cp"><?php</span> <span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">product_options</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">'rowid'</span><span class="p">])</span> <span class="k">as</span> <span class="nv">$option_name</span> <span class="o">=></span> <span class="nv">$option_value</span><span class="p">)</span><span class="o">:</span> <span class="cp">?></span> + + <span class="p"><</span><span class="nt">strong</span><span class="p">></span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$option_name</span><span class="p">;</span> <span class="cp">?></span>:<span class="p"></</span><span class="nt">strong</span><span class="p">></span> <span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$option_value</span><span class="p">;</span> <span class="cp">?></span><span class="p"><</span><span class="nt">br</span> <span class="p">/></span> + + <span class="cp"><?php</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?></span> + <span class="p"></</span><span class="nt">p</span><span class="p">></span> + + <span class="cp"><?php</span> <span class="k">endif</span><span class="p">;</span> <span class="cp">?></span> + + <span class="p"></</span><span class="nt">td</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">"text-align:right"</span><span class="p">></span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">format_number</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">'price'</span><span class="p">]);</span> <span class="cp">?></span><span class="p"></</span><span class="nt">td</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">"text-align:right"</span><span class="p">></span>$<span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">format_number</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">'subtotal'</span><span class="p">]);</span> <span class="cp">?></span><span class="p"></</span><span class="nt">td</span><span class="p">></span> + <span class="p"></</span><span class="nt">tr</span><span class="p">></span> + +<span class="cp"><?php</span> <span class="nv">$i</span><span class="o">++</span><span class="p">;</span> <span class="cp">?></span> + +<span class="cp"><?php</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?></span> + +<span class="p"><</span><span class="nt">tr</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span> <span class="na">colspan</span><span class="o">=</span><span class="s">"2"</span><span class="p">></span> <span class="p"></</span><span class="nt">td</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span> <span class="na">class</span><span class="o">=</span><span class="s">"right"</span><span class="p">><</span><span class="nt">strong</span><span class="p">></span>Total<span class="p"></</span><span class="nt">strong</span><span class="p">></</span><span class="nt">td</span><span class="p">></span> + <span class="p"><</span><span class="nt">td</span> <span class="na">class</span><span class="o">=</span><span class="s">"right"</span><span class="p">></span>$<span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">format_number</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">total</span><span class="p">());</span> <span class="cp">?></span><span class="p"></</span><span class="nt">td</span><span class="p">></span> +<span class="p"></</span><span class="nt">tr</span><span class="p">></span> + +<span class="p"></</span><span class="nt">table</span><span class="p">></span> + +<span class="p"><</span><span class="nt">p</span><span class="p">></span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_submit</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span> <span class="s1">'Update your Cart'</span><span class="p">);</span> <span class="cp">?></span><span class="p"></</span><span class="nt">p</span><span class="p">></span> +</pre></div> +</div> +</div> +<div class="section" id="updating-the-cart"> +<h3><a class="toc-backref" href="#id6">Updating The Cart</a><a class="headerlink" href="#updating-the-cart" title="Permalink to this headline">¶</a></h3> +<p>To update the information in your cart, you must pass an array +containing the Row ID and one or more pre-defined properties to the +<code class="docutils literal"><span class="pre">$this->cart->update()</span></code> method.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If the quantity is set to zero, the item will be removed from +the cart.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'rowid'</span> <span class="o">=></span> <span class="s1">'b99ccdf16028f015540f341130b6d8ec'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">3</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">update</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> + +<span class="c1">// Or a multi-dimensional array</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'rowid'</span> <span class="o">=></span> <span class="s1">'b99ccdf16028f015540f341130b6d8ec'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">3</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'rowid'</span> <span class="o">=></span> <span class="s1">'xw82g9q3r495893iajdh473990rikw23'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">4</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'rowid'</span> <span class="o">=></span> <span class="s1">'fh4kdkkkaoe30njgoe92rkdkkobec333'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">2</span> + <span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">update</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>You may also update any property you have previously defined when +inserting the item such as options, price or other custom fields.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'rowid'</span> <span class="o">=></span> <span class="s1">'b99ccdf16028f015540f341130b6d8ec'</span><span class="p">,</span> + <span class="s1">'qty'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> + <span class="s1">'price'</span> <span class="o">=></span> <span class="mf">49.95</span><span class="p">,</span> + <span class="s1">'coupon'</span> <span class="o">=></span> <span class="k">NULL</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">cart</span><span class="o">-></span><span class="na">update</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<div class="section" id="what-is-a-row-id"> +<h4><a class="toc-backref" href="#id7">What is a Row ID?</a><a class="headerlink" href="#what-is-a-row-id" title="Permalink to this headline">¶</a></h4> +<p>The row ID is a unique identifier that is generated by the cart code +when an item is added to the cart. The reason a unique ID is created +is so that identical products with different options can be managed +by the cart.</p> +<p>For example, let’s say someone buys two identical t-shirts (same product +ID), but in different sizes. The product ID (and other attributes) will +be identical for both sizes because it’s the same shirt. The only +difference will be the size. The cart must therefore have a means of +identifying this difference so that the two sizes of shirts can be +managed independently. It does so by creating a unique “row ID” based on +the product ID and any options associated with it.</p> +<p>In nearly all cases, updating the cart will be something the user does +via the “view cart” page, so as a developer, it is unlikely that you +will ever have to concern yourself with the “row ID”, other than making +sure your “view cart” page contains this information in a hidden form +field, and making sure it gets passed to the <code class="docutils literal"><span class="pre">update()</span></code> method when +the update form is submitted. Please examine the construction of the +“view cart” page above for more information.</p> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id8">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Cart"> +<em class="property">class </em><code class="descname">CI_Cart</code><a class="headerlink" href="#CI_Cart" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$product_id_rules = '.a-z0-9_-'</code></dt> +<dd><p>These are the regular expression rules that we use to validate the product +ID - alpha-numeric, dashes, underscores, or periods by default</p> +</dd></dl> + +<dl class="attribute"> +<dt> +<code class="descname">$product_name_rules = 'w -.:'</code></dt> +<dd><p>These are the regular expression rules that we use to validate the product ID and product name - alpha-numeric, dashes, underscores, colons or periods by +default</p> +</dd></dl> + +<dl class="attribute"> +<dt> +<code class="descname">$product_name_safe = TRUE</code></dt> +<dd><p>Whether or not to only allow safe product names. Default TRUE.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::insert"> +<code class="descname">insert</code><span class="sig-paren">(</span><span class="optional">[</span><em>$items = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::insert" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$items</strong> (<em>array</em>) – Items to insert into the cart</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Insert items into the cart and save it to the session table. Returns TRUE +on success and FALSE on failure.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::update"> +<code class="descname">update</code><span class="sig-paren">(</span><span class="optional">[</span><em>$items = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::update" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$items</strong> (<em>array</em>) – Items to update in the cart</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>This method permits changing the properties of a given item. +Typically it is called from the “view cart” page if a user makes changes +to the quantity before checkout. That array must contain the rowid +for each item.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::remove"> +<code class="descname">remove</code><span class="sig-paren">(</span><em>$rowid</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::remove" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$rowid</strong> (<em>int</em>) – ID of the item to remove from the cart</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Allows you to remove an item from the shopping cart by passing it the +<code class="docutils literal"><span class="pre">$rowid</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::total"> +<code class="descname">total</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::total" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Total amount</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td> +</tr> +</tbody> +</table> +<p>Displays the total amount in the cart.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::total_items"> +<code class="descname">total_items</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::total_items" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Total amount of items in the cart</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td> +</tr> +</tbody> +</table> +<p>Displays the total number of items in the cart.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::contents"> +<code class="descname">contents</code><span class="sig-paren">(</span><span class="optional">[</span><em>$newest_first = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::contents" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$newest_first</strong> (<em>bool</em>) – Whether to order the array with newest items first</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An array of cart contents</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns an array containing everything in the cart. You can sort the +order by which the array is returned by passing it TRUE where the contents +will be sorted from newest to oldest, otherwise it is sorted from oldest +to newest.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::get_item"> +<code class="descname">get_item</code><span class="sig-paren">(</span><em>$row_id</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::get_item" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$row_id</strong> (<em>int</em>) – Row ID to retrieve</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of item data</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns an array containing data for the item matching the specified row +ID, or FALSE if no such item exists.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::has_options"> +<code class="descname">has_options</code><span class="sig-paren">(</span><em>$row_id = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::has_options" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$row_id</strong> (<em>int</em>) – Row ID to inspect</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if options exist, FALSE otherwise</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Returns TRUE (boolean) if a particular row in the cart contains options. +This method is designed to be used in a loop with <code class="docutils literal"><span class="pre">contents()</span></code>, since +you must pass the rowid to this method, as shown in the Displaying +the Cart example above.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::product_options"> +<code class="descname">product_options</code><span class="sig-paren">(</span><span class="optional">[</span><em>$row_id = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::product_options" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$row_id</strong> (<em>int</em>) – Row ID</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of product options</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns an array of options for a particular product. This method is +designed to be used in a loop with <code class="docutils literal"><span class="pre">contents()</span></code>, since you +must pass the rowid to this method, as shown in the Displaying the +Cart example above.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Cart::destroy"> +<code class="descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::destroy" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> +</tr> +</tbody> +</table> +<p>Permits you to destroy the cart. This method will likely be called +when you are finished processing the customer’s order.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="config.html" class="btn btn-neutral float-right" title="Config Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="calendar.html" class="btn btn-neutral" title="Calendaring Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html new file mode 100644 index 000000000..d3154ab02 --- /dev/null +++ b/user_guide/libraries/config.html @@ -0,0 +1,834 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Config Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Email Class" href="email.html"/> + <link rel="prev" title="Shopping Cart Class" href="cart.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Config Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="config-class"> +<h1>Config Class<a class="headerlink" href="#config-class" title="Permalink to this headline">¶</a></h1> +<p>The Config class provides a means to retrieve configuration preferences. +These preferences can come from the default config file +(application/config/config.php) or from your own custom config files.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This class is initialized automatically by the system so there +is no need to do it manually.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#working-with-the-config-class" id="id1">Working with the Config Class</a><ul> +<li><a class="reference internal" href="#anatomy-of-a-config-file" id="id2">Anatomy of a Config File</a></li> +<li><a class="reference internal" href="#loading-a-config-file" id="id3">Loading a Config File</a><ul> +<li><a class="reference internal" href="#manual-loading" id="id4">Manual Loading</a></li> +<li><a class="reference internal" href="#auto-loading" id="id5">Auto-loading</a></li> +</ul> +</li> +<li><a class="reference internal" href="#fetching-config-items" id="id6">Fetching Config Items</a></li> +<li><a class="reference internal" href="#setting-a-config-item" id="id7">Setting a Config Item</a></li> +<li><a class="reference internal" href="#environments" id="id8">Environments</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id9">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="working-with-the-config-class"> +<h2><a class="toc-backref" href="#id1">Working with the Config Class</a><a class="headerlink" href="#working-with-the-config-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="anatomy-of-a-config-file"> +<h3><a class="toc-backref" href="#id2">Anatomy of a Config File</a><a class="headerlink" href="#anatomy-of-a-config-file" title="Permalink to this headline">¶</a></h3> +<p>By default, CodeIgniter has one primary config file, located at +application/config/config.php. If you open the file using your text +editor you’ll see that config items are stored in an array called +$config.</p> +<p>You can add your own config items to this file, or if you prefer to keep +your configuration items separate (assuming you even need config items), +simply create your own file and save it in config folder.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If you do create your own config files use the same format as +the primary one, storing your items in an array called $config. +CodeIgniter will intelligently manage these files so there will be no +conflict even though the array has the same name (assuming an array +index is not named the same as another).</p> +</div> +</div> +<div class="section" id="loading-a-config-file"> +<h3><a class="toc-backref" href="#id3">Loading a Config File</a><a class="headerlink" href="#loading-a-config-file" title="Permalink to this headline">¶</a></h3> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">CodeIgniter automatically loads the primary config file +(application/config/config.php), so you will only need to load a config +file if you have created your own.</p> +</div> +<p>There are two ways to load a config file:</p> +<div class="section" id="manual-loading"> +<h4><a class="toc-backref" href="#id4">Manual Loading</a><a class="headerlink" href="#manual-loading" title="Permalink to this headline">¶</a></h4> +<p>To load one of your custom config files you will use the following +function within the <a class="reference internal" href="../general/controllers.html"><span class="doc">controller</span></a> that +needs it:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'filename'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where filename is the name of your config file, without the .php file +extension.</p> +<p>If you need to load multiple config files normally they will be +merged into one master config array. Name collisions can occur, +however, if you have identically named array indexes in different +config files. To avoid collisions you can set the second parameter to +TRUE and each config file will be stored in an array index +corresponding to the name of the config file. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Stored in an array with this prototype: $this->config['blog_settings'] = $config</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'blog_settings'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +<p>Please see the section entitled Fetching Config Items below to learn +how to retrieve config items set this way.</p> +<p>The third parameter allows you to suppress errors in the event that a +config file does not exist:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'blog_settings'</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="auto-loading"> +<h4><a class="toc-backref" href="#id5">Auto-loading</a><a class="headerlink" href="#auto-loading" title="Permalink to this headline">¶</a></h4> +<p>If you find that you need a particular config file globally, you can +have it loaded automatically by the system. To do this, open the +<strong>autoload.php</strong> file, located at application/config/autoload.php, +and add your config file as indicated in the file.</p> +</div> +</div> +<div class="section" id="fetching-config-items"> +<h3><a class="toc-backref" href="#id6">Fetching Config Items</a><a class="headerlink" href="#fetching-config-items" title="Permalink to this headline">¶</a></h3> +<p>To retrieve an item from your config file, use the following function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">item</span><span class="p">(</span><span class="s1">'item_name'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where item_name is the $config array index you want to retrieve. For +example, to fetch your language choice you’ll do this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$lang</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">item</span><span class="p">(</span><span class="s1">'language'</span><span class="p">);</span> +</pre></div> +</div> +<p>The function returns NULL if the item you are trying to fetch +does not exist.</p> +<p>If you are using the second parameter of the $this->config->load +function in order to assign your config items to a specific index you +can retrieve it by specifying the index name in the second parameter of +the $this->config->item() function. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Loads a config file named blog_settings.php and assigns it to an index named "blog_settings"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'blog_settings'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> + +<span class="c1">// Retrieve a config item named site_name contained within the blog_settings array</span> +<span class="nv">$site_name</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">item</span><span class="p">(</span><span class="s1">'site_name'</span><span class="p">,</span> <span class="s1">'blog_settings'</span><span class="p">);</span> + +<span class="c1">// An alternate way to specify the same item:</span> +<span class="nv">$blog_config</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">item</span><span class="p">(</span><span class="s1">'blog_settings'</span><span class="p">);</span> +<span class="nv">$site_name</span> <span class="o">=</span> <span class="nv">$blog_config</span><span class="p">[</span><span class="s1">'site_name'</span><span class="p">];</span> +</pre></div> +</div> +</div> +<div class="section" id="setting-a-config-item"> +<h3><a class="toc-backref" href="#id7">Setting a Config Item</a><a class="headerlink" href="#setting-a-config-item" title="Permalink to this headline">¶</a></h3> +<p>If you would like to dynamically set a config item or change an existing +one, you can do so using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">config</span><span class="o">-></span><span class="na">set_item</span><span class="p">(</span><span class="s1">'item_name'</span><span class="p">,</span> <span class="s1">'item_value'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where item_name is the $config array index you want to change, and +item_value is its value.</p> +</div> +<div class="section" id="environments"> +<span id="config-environments"></span><h3><a class="toc-backref" href="#id8">Environments</a><a class="headerlink" href="#environments" title="Permalink to this headline">¶</a></h3> +<p>You may load different configuration files depending on the current +environment. The ENVIRONMENT constant is defined in index.php, and is +described in detail in the <a class="reference internal" href="../general/environments.html"><span class="doc">Handling +Environments</span></a> section.</p> +<p>To create an environment-specific configuration file, create or copy a +configuration file in application/config/{ENVIRONMENT}/{FILENAME}.php</p> +<p>For example, to create a production-only config.php, you would:</p> +<ol class="arabic simple"> +<li>Create the directory application/config/production/</li> +<li>Copy your existing config.php into the above directory</li> +<li>Edit application/config/production/config.php so it contains your +production settings</li> +</ol> +<p>When you set the ENVIRONMENT constant to ‘production’, the settings for +your new production-only config.php will be loaded.</p> +<p>You can place the following configuration files in environment-specific +folders:</p> +<ul class="simple"> +<li>Default CodeIgniter configuration files</li> +<li>Your own custom configuration files</li> +</ul> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">CodeIgniter always loads the global config file first (i.e., the one in application/config/), +then tries to load the configuration files for the current environment. +This means you are not obligated to place <strong>all</strong> of your configuration files in an +environment folder. Only the files that change per environment. Additionally you don’t +have to copy <strong>all</strong> the config items in the environment config file. Only the config items +that you wish to change for your environment. The config items declared in your environment +folders always overwrite those in your global config files.</p> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id9">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Config"> +<em class="property">class </em><code class="descname">CI_Config</code><a class="headerlink" href="#CI_Config" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$config</code></dt> +<dd><p>Array of all loaded config values</p> +</dd></dl> + +<dl class="attribute"> +<dt> +<code class="descname">$is_loaded</code></dt> +<dd><p>Array of all loaded config files</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::item"> +<code class="descname">item</code><span class="sig-paren">(</span><em>$item</em><span class="optional">[</span>, <em>$index=''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::item" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$item</strong> (<em>string</em>) – Config item name</li> +<li><strong>$index</strong> (<em>string</em>) – Index name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Config item value or NULL if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Fetch a config file item.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::set_item"> +<code class="descname">set_item</code><span class="sig-paren">(</span><em>$item</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::set_item" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$item</strong> (<em>string</em>) – Config item name</li> +<li><strong>$value</strong> (<em>string</em>) – Config item value</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets a config file item to the specified value.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::slash_item"> +<code class="descname">slash_item</code><span class="sig-paren">(</span><em>$item</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::slash_item" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$item</strong> (<em>string</em>) – config item name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Config item value with a trailing forward slash or NULL if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">item()</span></code>, except it appends a forward +slash to the end of the item, if it exists.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::load"> +<code class="descname">load</code><span class="sig-paren">(</span><span class="optional">[</span><em>$file = ''</em><span class="optional">[</span>, <em>$use_sections = FALSE</em><span class="optional">[</span>, <em>$fail_gracefully = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::load" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$file</strong> (<em>string</em>) – Configuration file name</li> +<li><strong>$use_sections</strong> (<em>bool</em>) – Whether config values should be loaded into their own section (index of the main config array)</li> +<li><strong>$fail_gracefully</strong> (<em>bool</em>) – Whether to return FALSE or to display an error message</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Loads a configuration file.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::site_url"> +<code class="descname">site_url</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::site_url" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Site URL</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>This method retrieves the URL to your site, along with the “index” value +you’ve specified in the config file.</p> +<p>This method is normally accessed via the corresponding functions in the +<a class="reference internal" href="../helpers/url_helper.html"><span class="doc">URL Helper</span></a>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::base_url"> +<code class="descname">base_url</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::base_url" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Base URL</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>This method retrieves the URL to your site, plus an optional path such +as to a stylesheet or image.</p> +<p>This method is normally accessed via the corresponding functions in the +<a class="reference internal" href="../helpers/url_helper.html"><span class="doc">URL Helper</span></a>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Config::system_url"> +<code class="descname">system_url</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Config::system_url" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">URL pointing at your CI system/ directory</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>This method retrieves the URL to your CodeIgniter system/ directory.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is DEPRECATED because it encourages usage of +insecure coding practices. Your <em>system/</em> directory shouldn’t +be publicly accessible.</p> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="email.html" class="btn btn-neutral float-right" title="Email Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="cart.html" class="btn btn-neutral" title="Shopping Cart Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/email.html b/user_guide/libraries/email.html new file mode 100644 index 000000000..4b6d7dc5a --- /dev/null +++ b/user_guide/libraries/email.html @@ -0,0 +1,1218 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Email Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Encrypt Class" href="encrypt.html"/> + <link rel="prev" title="Config Class" href="config.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Email Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="email-class"> +<h1>Email Class<a class="headerlink" href="#email-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s robust Email Class supports the following features:</p> +<ul class="simple"> +<li>Multiple Protocols: Mail, Sendmail, and SMTP</li> +<li>TLS and SSL Encryption for SMTP</li> +<li>Multiple recipients</li> +<li>CC and BCCs</li> +<li>HTML or Plaintext email</li> +<li>Attachments</li> +<li>Word wrapping</li> +<li>Priorities</li> +<li>BCC Batch Mode, enabling large email lists to be broken into small +BCC batches.</li> +<li>Email Debugging tools</li> +</ul> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-email-library" id="id1">Using the Email Library</a><ul> +<li><a class="reference internal" href="#sending-email" id="id2">Sending Email</a></li> +<li><a class="reference internal" href="#setting-email-preferences" id="id3">Setting Email Preferences</a><ul> +<li><a class="reference internal" href="#setting-email-preferences-in-a-config-file" id="id4">Setting Email Preferences in a Config File</a></li> +</ul> +</li> +<li><a class="reference internal" href="#email-preferences" id="id5">Email Preferences</a></li> +<li><a class="reference internal" href="#overriding-word-wrapping" id="id6">Overriding Word Wrapping</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id7">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-email-library"> +<h2><a class="toc-backref" href="#id1">Using the Email Library</a><a class="headerlink" href="#using-the-email-library" title="Permalink to this headline">¶</a></h2> +<div class="section" id="sending-email"> +<h3><a class="toc-backref" href="#id2">Sending Email</a><a class="headerlink" href="#sending-email" title="Permalink to this headline">¶</a></h3> +<p>Sending email is not only simple, but you can configure it on the fly or +set your preferences in a config file.</p> +<p>Here is a basic example demonstrating how you might send email. Note: +This example assumes you are sending the email from one of your +<a class="reference internal" href="../general/controllers.html"><span class="doc">controllers</span></a>.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'email'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">from</span><span class="p">(</span><span class="s1">'your@example.com'</span><span class="p">,</span> <span class="s1">'Your Name'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">to</span><span class="p">(</span><span class="s1">'someone@example.com'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">cc</span><span class="p">(</span><span class="s1">'another@another-example.com'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">bcc</span><span class="p">(</span><span class="s1">'them@their-example.com'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">subject</span><span class="p">(</span><span class="s1">'Email Test'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">message</span><span class="p">(</span><span class="s1">'Testing the email class.'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">send</span><span class="p">();</span> +</pre></div> +</div> +</div> +<div class="section" id="setting-email-preferences"> +<h3><a class="toc-backref" href="#id3">Setting Email Preferences</a><a class="headerlink" href="#setting-email-preferences" title="Permalink to this headline">¶</a></h3> +<p>There are 21 different preferences available to tailor how your email +messages are sent. You can either set them manually as described here, +or automatically via preferences stored in your config file, described +below:</p> +<p>Preferences are set by passing an array of preference values to the +email initialize method. Here is an example of how you might set some +preferences:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'protocol'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'sendmail'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'mailpath'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/usr/sbin/sendmail'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'charset'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'iso-8859-1'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wordwrap'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Most of the preferences have default values that will be used +if you do not set them.</p> +</div> +<div class="section" id="setting-email-preferences-in-a-config-file"> +<h4><a class="toc-backref" href="#id4">Setting Email Preferences in a Config File</a><a class="headerlink" href="#setting-email-preferences-in-a-config-file" title="Permalink to this headline">¶</a></h4> +<p>If you prefer not to set preferences using the above method, you can +instead put them into a config file. Simply create a new file called the +email.php, add the $config array in that file. Then save the file at +config/email.php and it will be used automatically. You will NOT need to +use the <code class="docutils literal"><span class="pre">$this->email->initialize()</span></code> method if you save your +preferences in a config file.</p> +</div> +</div> +<div class="section" id="email-preferences"> +<h3><a class="toc-backref" href="#id5">Email Preferences</a><a class="headerlink" href="#email-preferences" title="Permalink to this headline">¶</a></h3> +<p>The following is a list of all the preferences that can be set when +sending email.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="14%" /> +<col width="16%" /> +<col width="20%" /> +<col width="51%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default Value</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>useragent</strong></td> +<td>CodeIgniter</td> +<td>None</td> +<td>The “user agent”.</td> +</tr> +<tr class="row-odd"><td><strong>protocol</strong></td> +<td>mail</td> +<td>mail, sendmail, or smtp</td> +<td>The mail sending protocol.</td> +</tr> +<tr class="row-even"><td><strong>mailpath</strong></td> +<td>/usr/sbin/sendmail</td> +<td>None</td> +<td>The server path to Sendmail.</td> +</tr> +<tr class="row-odd"><td><strong>smtp_host</strong></td> +<td>No Default</td> +<td>None</td> +<td>SMTP Server Address.</td> +</tr> +<tr class="row-even"><td><strong>smtp_user</strong></td> +<td>No Default</td> +<td>None</td> +<td>SMTP Username.</td> +</tr> +<tr class="row-odd"><td><strong>smtp_pass</strong></td> +<td>No Default</td> +<td>None</td> +<td>SMTP Password.</td> +</tr> +<tr class="row-even"><td><strong>smtp_port</strong></td> +<td>25</td> +<td>None</td> +<td>SMTP Port.</td> +</tr> +<tr class="row-odd"><td><strong>smtp_timeout</strong></td> +<td>5</td> +<td>None</td> +<td>SMTP Timeout (in seconds).</td> +</tr> +<tr class="row-even"><td><strong>smtp_keepalive</strong></td> +<td>FALSE</td> +<td>TRUE or FALSE (boolean)</td> +<td>Enable persistent SMTP connections.</td> +</tr> +<tr class="row-odd"><td><strong>smtp_crypto</strong></td> +<td>No Default</td> +<td>tls or ssl</td> +<td>SMTP Encryption</td> +</tr> +<tr class="row-even"><td><strong>wordwrap</strong></td> +<td>TRUE</td> +<td>TRUE or FALSE (boolean)</td> +<td>Enable word-wrap.</td> +</tr> +<tr class="row-odd"><td><strong>wrapchars</strong></td> +<td>76</td> +<td> </td> +<td>Character count to wrap at.</td> +</tr> +<tr class="row-even"><td><strong>mailtype</strong></td> +<td>text</td> +<td>text or html</td> +<td>Type of mail. If you send HTML email you must send it as a complete web +page. Make sure you don’t have any relative links or relative image +paths otherwise they will not work.</td> +</tr> +<tr class="row-odd"><td><strong>charset</strong></td> +<td><code class="docutils literal"><span class="pre">$config['charset']</span></code></td> +<td> </td> +<td>Character set (utf-8, iso-8859-1, etc.).</td> +</tr> +<tr class="row-even"><td><strong>validate</strong></td> +<td>FALSE</td> +<td>TRUE or FALSE (boolean)</td> +<td>Whether to validate the email address.</td> +</tr> +<tr class="row-odd"><td><strong>priority</strong></td> +<td>3</td> +<td>1, 2, 3, 4, 5</td> +<td>Email Priority. 1 = highest. 5 = lowest. 3 = normal.</td> +</tr> +<tr class="row-even"><td><strong>crlf</strong></td> +<td>\n</td> +<td>“\r\n” or “\n” or “\r”</td> +<td>Newline character. (Use “\r\n” to comply with RFC 822).</td> +</tr> +<tr class="row-odd"><td><strong>newline</strong></td> +<td>\n</td> +<td>“\r\n” or “\n” or “\r”</td> +<td>Newline character. (Use “\r\n” to comply with RFC 822).</td> +</tr> +<tr class="row-even"><td><strong>bcc_batch_mode</strong></td> +<td>FALSE</td> +<td>TRUE or FALSE (boolean)</td> +<td>Enable BCC Batch Mode.</td> +</tr> +<tr class="row-odd"><td><strong>bcc_batch_size</strong></td> +<td>200</td> +<td>None</td> +<td>Number of emails in each BCC batch.</td> +</tr> +<tr class="row-even"><td><strong>dsn</strong></td> +<td>FALSE</td> +<td>TRUE or FALSE (boolean)</td> +<td>Enable notify message from server</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="overriding-word-wrapping"> +<h3><a class="toc-backref" href="#id6">Overriding Word Wrapping</a><a class="headerlink" href="#overriding-word-wrapping" title="Permalink to this headline">¶</a></h3> +<p>If you have word wrapping enabled (recommended to comply with RFC 822) +and you have a very long link in your email it can get wrapped too, +causing it to become un-clickable by the person receiving it. +CodeIgniter lets you manually override word wrapping within part of your +message like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">The</span> <span class="nx">text</span> <span class="nx">of</span> <span class="nx">your</span> <span class="nx">email</span> <span class="nx">that</span> +<span class="nx">gets</span> <span class="nx">wrapped</span> <span class="nx">normally</span><span class="o">.</span> + +<span class="p">{</span><span class="nx">unwrap</span><span class="p">}</span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">a_long_link_that_should_not_be_wrapped</span><span class="o">.</span><span class="nx">html</span><span class="p">{</span><span class="o">/</span><span class="nx">unwrap</span><span class="p">}</span> + +<span class="nx">More</span> <span class="nx">text</span> <span class="nx">that</span> <span class="nx">will</span> <span class="nx">be</span> +<span class="nx">wrapped</span> <span class="nx">normally</span><span class="o">.</span> +</pre></div> +</div> +<p>Place the item you do not want word-wrapped between: {unwrap} {/unwrap}</p> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id7">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Email"> +<em class="property">class </em><code class="descname">CI_Email</code><a class="headerlink" href="#CI_Email" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Email::from"> +<code class="descname">from</code><span class="sig-paren">(</span><em>$from</em><span class="optional">[</span>, <em>$name = ''</em><span class="optional">[</span>, <em>$return_path = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::from" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$from</strong> (<em>string</em>) – “From” e-mail address</li> +<li><strong>$name</strong> (<em>string</em>) – “From” display name</li> +<li><strong>$return_path</strong> (<em>string</em>) – Optional email address to redirect undelivered e-mail to</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the email address and name of the person sending the email:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">from</span><span class="p">(</span><span class="s1">'you@example.com'</span><span class="p">,</span> <span class="s1">'Your Name'</span><span class="p">);</span> +</pre></div> +</div> +<p>You can also set a Return-Path, to help redirect undelivered mail:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">from</span><span class="p">(</span><span class="s1">'you@example.com'</span><span class="p">,</span> <span class="s1">'Your Name'</span><span class="p">,</span> <span class="s1">'returned_emails@example.com'</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Return-Path can’t be used if you’ve configured ‘smtp’ as +your protocol.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::reply_to"> +<code class="descname">reply_to</code><span class="sig-paren">(</span><em>$replyto</em><span class="optional">[</span>, <em>$name = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::reply_to" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$replyto</strong> (<em>string</em>) – E-mail address for replies</li> +<li><strong>$name</strong> (<em>string</em>) – Display name for the reply-to e-mail address</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the reply-to address. If the information is not provided the +information in the :meth:from method is used. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">reply_to</span><span class="p">(</span><span class="s1">'you@example.com'</span><span class="p">,</span> <span class="s1">'Your Name'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::to"> +<code class="descname">to</code><span class="sig-paren">(</span><em>$to</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::to" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$to</strong> (<em>mixed</em>) – Comma-delimited string or an array of e-mail addresses</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the email address(s) of the recipient(s). Can be a single e-mail, +a comma-delimited list or an array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">to</span><span class="p">(</span><span class="s1">'someone@example.com'</span><span class="p">);</span> +</pre></div> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">to</span><span class="p">(</span><span class="s1">'one@example.com, two@example.com, three@example.com'</span><span class="p">);</span> +</pre></div> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">to</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'one@example.com'</span><span class="p">,</span> <span class="s1">'two@example.com'</span><span class="p">,</span> <span class="s1">'three@example.com'</span><span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::cc"> +<code class="descname">cc</code><span class="sig-paren">(</span><em>$cc</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::cc" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$cc</strong> (<em>mixed</em>) – Comma-delimited string or an array of e-mail addresses</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the CC email address(s). Just like the “to”, can be a single e-mail, +a comma-delimited list or an array.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::bcc"> +<code class="descname">bcc</code><span class="sig-paren">(</span><em>$bcc</em><span class="optional">[</span>, <em>$limit = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::bcc" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$bcc</strong> (<em>mixed</em>) – Comma-delimited string or an array of e-mail addresses</li> +<li><strong>$limit</strong> (<em>int</em>) – Maximum number of e-mails to send per batch</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the BCC email address(s). Just like the <code class="docutils literal"><span class="pre">to()</span></code> method, can be a single +e-mail, a comma-delimited list or an array.</p> +<p>If <code class="docutils literal"><span class="pre">$limit</span></code> is set, “batch mode” will be enabled, which will send +the emails to batches, with each batch not exceeding the specified +<code class="docutils literal"><span class="pre">$limit</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::subject"> +<code class="descname">subject</code><span class="sig-paren">(</span><em>$subject</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::subject" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$subject</strong> (<em>string</em>) – E-mail subject line</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the email subject:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">subject</span><span class="p">(</span><span class="s1">'This is my subject'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::message"> +<code class="descname">message</code><span class="sig-paren">(</span><em>$body</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::message" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$body</strong> (<em>string</em>) – E-mail message body</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the e-mail message body:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">message</span><span class="p">(</span><span class="s1">'This is my message'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::set_alt_message"> +<code class="descname">set_alt_message</code><span class="sig-paren">(</span><em>$str</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::set_alt_message" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Alternative e-mail message body</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the alternative e-mail message body:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">set_alt_message</span><span class="p">(</span><span class="s1">'This is the alternative message'</span><span class="p">);</span> +</pre></div> +</div> +<p>This is an optional message string which can be used if you send +HTML formatted email. It lets you specify an alternative message +with no HTML formatting which is added to the header string for +people who do not accept HTML email. If you do not set your own +message CodeIgniter will extract the message from your HTML email +and strip the tags.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::set_header"> +<code class="descname">set_header</code><span class="sig-paren">(</span><em>$header</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::set_header" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$header</strong> (<em>string</em>) – Header name</li> +<li><strong>$value</strong> (<em>string</em>) – Header value</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Appends additional headers to the e-mail:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'Header1'</span><span class="p">,</span> <span class="s1">'Value1'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'Header2'</span><span class="p">,</span> <span class="s1">'Value2'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::clear"> +<code class="descname">clear</code><span class="sig-paren">(</span><span class="optional">[</span><em>$clear_attachments = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::clear" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$clear_attachments</strong> (<em>bool</em>) – Whether or not to clear attachments</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Initializes all the email variables to an empty state. This method +is intended for use if you run the email sending method in a loop, +permitting the data to be reset between cycles.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">foreach</span> <span class="p">(</span><span class="nv">$list</span> <span class="k">as</span> <span class="nv">$name</span> <span class="o">=></span> <span class="nv">$address</span><span class="p">)</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">clear</span><span class="p">();</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">to</span><span class="p">(</span><span class="nv">$address</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">from</span><span class="p">(</span><span class="s1">'your@example.com'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">subject</span><span class="p">(</span><span class="s1">'Here is your info '</span><span class="o">.</span><span class="nv">$name</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">message</span><span class="p">(</span><span class="s1">'Hi '</span><span class="o">.</span><span class="nv">$name</span><span class="o">.</span><span class="s1">' Here is the info you requested.'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">send</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +<p>If you set the parameter to TRUE any attachments will be cleared as +well:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">clear</span><span class="p">(</span><span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::send"> +<code class="descname">send</code><span class="sig-paren">(</span><span class="optional">[</span><em>$auto_clear = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::send" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$auto_clear</strong> (<em>bool</em>) – Whether to clear message data automatically</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>The e-mail sending method. Returns boolean TRUE or FALSE based on +success or failure, enabling it to be used conditionally:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">send</span><span class="p">())</span> +<span class="p">{</span> + <span class="c1">// Generate error</span> +<span class="p">}</span> +</pre></div> +</div> +<p>This method will automatically clear all parameters if the request was +successful. To stop this behaviour pass FALSE:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">send</span><span class="p">(</span><span class="k">FALSE</span><span class="p">))</span> +<span class="p">{</span> + <span class="c1">// Parameters won't be cleared</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In order to use the <code class="docutils literal"><span class="pre">print_debugger()</span></code> method, you need +to avoid clearing the email parameters.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::attach"> +<code class="descname">attach</code><span class="sig-paren">(</span><em>$filename</em><span class="optional">[</span>, <em>$disposition = ''</em><span class="optional">[</span>, <em>$newname = NULL</em><span class="optional">[</span>, <em>$mime = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::attach" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filename</strong> (<em>string</em>) – File name</li> +<li><strong>$disposition</strong> (<em>string</em>) – ‘disposition’ of the attachment. Most +email clients make their own decision regardless of the MIME +specification used here. <a class="reference external" href="https://www.iana.org/assignments/cont-disp/cont-disp.xhtml">https://www.iana.org/assignments/cont-disp/cont-disp.xhtml</a></li> +<li><strong>$newname</strong> (<em>string</em>) – Custom file name to use in the e-mail</li> +<li><strong>$mime</strong> (<em>string</em>) – MIME type to use (useful for buffered data)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Email instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Email</p> +</td> +</tr> +</tbody> +</table> +<p>Enables you to send an attachment. Put the file path/name in the first +parameter. For multiple attachments use the method multiple times. +For example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="s1">'/path/to/photo1.jpg'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="s1">'/path/to/photo2.jpg'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="s1">'/path/to/photo3.jpg'</span><span class="p">);</span> +</pre></div> +</div> +<p>To use the default disposition (attachment), leave the second parameter blank, +otherwise use a custom disposition:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="s1">'image.jpg'</span><span class="p">,</span> <span class="s1">'inline'</span><span class="p">);</span> +</pre></div> +</div> +<p>You can also use a URL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="s1">'http://example.com/filename.pdf'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you’d like to use a custom file name, you can use the third parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="s1">'filename.pdf'</span><span class="p">,</span> <span class="s1">'attachment'</span><span class="p">,</span> <span class="s1">'report.pdf'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you need to use a buffer string instead of a real - physical - file you can +use the first parameter as buffer, the third parameter as file name and the fourth +parameter as mime-type:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="nv">$buffer</span><span class="p">,</span> <span class="s1">'attachment'</span><span class="p">,</span> <span class="s1">'report.pdf'</span><span class="p">,</span> <span class="s1">'application/pdf'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::attachment_cid"> +<code class="descname">attachment_cid</code><span class="sig-paren">(</span><em>$filename</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::attachment_cid" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filename</strong> (<em>string</em>) – Existing attachment filename</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Attachment Content-ID or FALSE if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Sets and returns an attachment’s Content-ID, which enables your to embed an inline +(picture) attachment into HTML. First parameter must be the already attached file name.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$filename</span> <span class="o">=</span> <span class="s1">'/img/photo1.jpg'</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attach</span><span class="p">(</span><span class="nv">$filename</span><span class="p">);</span> +<span class="k">foreach</span> <span class="p">(</span><span class="nv">$list</span> <span class="k">as</span> <span class="nv">$address</span><span class="p">)</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">to</span><span class="p">(</span><span class="nv">$address</span><span class="p">);</span> + <span class="nv">$cid</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">attachment_cid</span><span class="p">(</span><span class="nv">$filename</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">message</span><span class="p">(</span><span class="s1">'<img src="cid:'</span><span class="o">.</span> <span class="nv">$cid</span> <span class="o">.</span><span class="s1">'" alt="photo1" />'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">send</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Content-ID for each e-mail must be re-created for it to be unique.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Email::print_debugger"> +<code class="descname">print_debugger</code><span class="sig-paren">(</span><span class="optional">[</span><em>$include = array('headers'</em>, <em>'subject'</em>, <em>'body')</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Email::print_debugger" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$include</strong> (<em>array</em>) – Which parts of the message to print out</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Formatted debug data</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns a string containing any server messages, the email headers, and +the email message. Useful for debugging.</p> +<p>You can optionally specify which parts of the message should be printed. +Valid options are: <strong>headers</strong>, <strong>subject</strong>, <strong>body</strong>.</p> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// You need to pass FALSE while sending in order for the email data</span> +<span class="c1">// to not be cleared - if that happens, print_debugger() would have</span> +<span class="c1">// nothing to output.</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">send</span><span class="p">(</span><span class="k">FALSE</span><span class="p">);</span> + +<span class="c1">// Will only print the email headers, excluding the message subject and body</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">email</span><span class="o">-></span><span class="na">print_debugger</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'headers'</span><span class="p">));</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">By default, all of the raw data will be printed.</p> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="encrypt.html" class="btn btn-neutral float-right" title="Encrypt Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="config.html" class="btn btn-neutral" title="Config Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/encrypt.html b/user_guide/libraries/encrypt.html new file mode 100644 index 000000000..76755cdf0 --- /dev/null +++ b/user_guide/libraries/encrypt.html @@ -0,0 +1,787 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Encrypt Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Encryption Library" href="encryption.html"/> + <link rel="prev" title="Email Class" href="email.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Encrypt Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="encrypt-class"> +<h1>Encrypt Class<a class="headerlink" href="#encrypt-class" title="Permalink to this headline">¶</a></h1> +<p>The Encrypt Class provides two-way data encryption. It encrypted using +the Mcrypt PHP extension, which is required for the Encrypt Class to run.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">This library has been DEPRECATED and is only kept for +backwards compatibility. Please use the new <a class="reference internal" href="encryption.html"><span class="doc">Encryption Library</span></a>.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-encrypt-library" id="id1">Using the Encrypt Library</a><ul> +<li><a class="reference internal" href="#setting-your-key" id="id2">Setting your Key</a></li> +<li><a class="reference internal" href="#message-length" id="id3">Message Length</a></li> +<li><a class="reference internal" href="#initializing-the-class" id="id4">Initializing the Class</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id5">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-encrypt-library"> +<h2><a class="toc-backref" href="#id1">Using the Encrypt Library</a><a class="headerlink" href="#using-the-encrypt-library" title="Permalink to this headline">¶</a></h2> +<div class="section" id="setting-your-key"> +<h3><a class="toc-backref" href="#id2">Setting your Key</a><a class="headerlink" href="#setting-your-key" title="Permalink to this headline">¶</a></h3> +<p>A <em>key</em> is a piece of information that controls the cryptographic +process and permits an encrypted string to be decoded. In fact, the key +you chose will provide the <strong>only</strong> means to decode data that was +encrypted with that key, so not only must you choose the key carefully, +you must never change it if you intend use it for persistent data.</p> +<p>It goes without saying that you should guard your key carefully. Should +someone gain access to your key, the data will be easily decoded. If +your server is not totally under your control it’s impossible to ensure +key security so you may want to think carefully before using it for +anything that requires high security, like storing credit card numbers.</p> +<p>To take maximum advantage of the encryption algorithm, your key should +be 32 characters in length (256 bits). The key should be as random a +string as you can concoct, with numbers and uppercase and lowercase +letters. Your key should <strong>not</strong> be a simple text string. In order to be +cryptographically secure it needs to be as random as possible.</p> +<p>Your key can be either stored in your <strong>application/config/config.php</strong>, or +you can design your own storage mechanism and pass the key dynamically +when encoding/decoding.</p> +<p>To save your key to your <strong>application/config/config.php</strong>, open the file +and set:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'encryption_key'</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"YOUR KEY"</span><span class="p">;</span> +</pre></div> +</div> +</div> +<div class="section" id="message-length"> +<h3><a class="toc-backref" href="#id3">Message Length</a><a class="headerlink" href="#message-length" title="Permalink to this headline">¶</a></h3> +<p>It’s important for you to know that the encoded messages the encryption +function generates will be approximately 2.6 times longer than the +original message. For example, if you encrypt the string “my super +secret data”, which is 21 characters in length, you’ll end up with an +encoded string that is roughly 55 characters (we say “roughly” because +the encoded string length increments in 64 bit clusters, so it’s not +exactly linear). Keep this information in mind when selecting your data +storage mechanism. Cookies, for example, can only hold 4K of +information.</p> +</div> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id4">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Encrypt class is +initialized in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> +method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'encrypt'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Encrypt library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id5">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Encrypt"> +<em class="property">class </em><code class="descname">CI_Encrypt</code><a class="headerlink" href="#CI_Encrypt" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Encrypt::encode"> +<code class="descname">encode</code><span class="sig-paren">(</span><em>$string</em><span class="optional">[</span>, <em>$key = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encrypt::encode" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$string</strong> (<em>string</em>) – Data to encrypt</li> +<li><strong>$key</strong> (<em>string</em>) – Encryption key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Encrypted string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Performs the data encryption and returns it as a string. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$msg</span> <span class="o">=</span> <span class="s1">'My secret message'</span><span class="p">;</span> + +<span class="nv">$encrypted_string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">encode</span><span class="p">(</span><span class="nv">$msg</span><span class="p">);</span> +</pre></div> +</div> +<p>You can optionally pass your encryption key via the second parameter if +you don’t want to use the one in your config file:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$msg</span> <span class="o">=</span> <span class="s1">'My secret message'</span><span class="p">;</span> +<span class="nv">$key</span> <span class="o">=</span> <span class="s1">'super-secret-key'</span><span class="p">;</span> + +<span class="nv">$encrypted_string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">encode</span><span class="p">(</span><span class="nv">$msg</span><span class="p">,</span> <span class="nv">$key</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encrypt::decode"> +<code class="descname">decode</code><span class="sig-paren">(</span><em>$string</em><span class="optional">[</span>, <em>$key = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encrypt::decode" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$string</strong> (<em>string</em>) – String to decrypt</li> +<li><strong>$key</strong> (<em>string</em>) – Encryption key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Plain-text string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Decrypts an encoded string. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$encrypted_string</span> <span class="o">=</span> <span class="s1">'APANtByIGI1BpVXZTJgcsAG8GZl8pdwwa84'</span><span class="p">;</span> + +<span class="nv">$plaintext_string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">decode</span><span class="p">(</span><span class="nv">$encrypted_string</span><span class="p">);</span> +</pre></div> +</div> +<p>You can optionally pass your encryption key via the second parameter if +you don’t want to use the one in your config file:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$msg</span> <span class="o">=</span> <span class="s1">'My secret message'</span><span class="p">;</span> +<span class="nv">$key</span> <span class="o">=</span> <span class="s1">'super-secret-key'</span><span class="p">;</span> + +<span class="nv">$encrypted_string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">decode</span><span class="p">(</span><span class="nv">$msg</span><span class="p">,</span> <span class="nv">$key</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encrypt::set_cipher"> +<code class="descname">set_cipher</code><span class="sig-paren">(</span><em>$cipher</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encrypt::set_cipher" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$cipher</strong> (<em>int</em>) – Valid PHP MCrypt cypher constant</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Encrypt instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Encrypt</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set an Mcrypt cipher. By default it uses +<code class="docutils literal"><span class="pre">MCRYPT_RIJNDAEL_256</span></code>. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">set_cipher</span><span class="p">(</span><span class="nx">MCRYPT_BLOWFISH</span><span class="p">);</span> +</pre></div> +</div> +<p>Please visit php.net for a list of <a class="reference external" href="http://php.net/mcrypt">available ciphers</a>.</p> +<p>If you’d like to manually test whether your server supports MCrypt you +can use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nb">extension_loaded</span><span class="p">(</span><span class="s1">'mcrypt'</span><span class="p">)</span> <span class="o">?</span> <span class="s1">'Yup'</span> <span class="o">:</span> <span class="s1">'Nope'</span><span class="p">;</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encrypt::set_mode"> +<code class="descname">set_mode</code><span class="sig-paren">(</span><em>$mode</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encrypt::set_mode" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$mode</strong> (<em>int</em>) – Valid PHP MCrypt mode constant</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Encrypt instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Encrypt</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set an Mcrypt mode. By default it uses <strong>MCRYPT_MODE_CBC</strong>. +Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">set_mode</span><span class="p">(</span><span class="nx">MCRYPT_MODE_CFB</span><span class="p">);</span> +</pre></div> +</div> +<p>Please visit php.net for a list of <a class="reference external" href="http://php.net/mcrypt">available modes</a>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encrypt::encode_from_legacy"> +<code class="descname">encode_from_legacy</code><span class="sig-paren">(</span><em>$string</em><span class="optional">[</span>, <em>$legacy_mode = MCRYPT_MODE_ECB</em><span class="optional">[</span>, <em>$key = ''</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encrypt::encode_from_legacy" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$string</strong> (<em>string</em>) – String to encrypt</li> +<li><strong>$legacy_mode</strong> (<em>int</em>) – Valid PHP MCrypt cipher constant</li> +<li><strong>$key</strong> (<em>string</em>) – Encryption key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Newly encrypted string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Enables you to re-encode data that was originally encrypted with +CodeIgniter 1.x to be compatible with the Encrypt library in +CodeIgniter 2.x. It is only necessary to use this method if you have +encrypted data stored permanently such as in a file or database and are +on a server that supports Mcrypt. “Light” use encryption such as +encrypted session data or transitory encrypted flashdata require no +intervention on your part. However, existing encrypted Sessions will be +destroyed since data encrypted prior to 2.x will not be decoded.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last"><strong>Why only a method to re-encode the data instead of maintaining legacy +methods for both encoding and decoding?</strong> The algorithms in the +Encrypt library have improved in CodeIgniter 2.x both for performance +and security, and we do not wish to encourage continued use of the older +methods. You can of course extend the Encryption library if you wish and +replace the new methods with the old and retain seamless compatibility +with CodeIgniter 1.x encrypted data, but this a decision that a +developer should make cautiously and deliberately, if at all.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$new_data</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encrypt</span><span class="o">-></span><span class="na">encode_from_legacy</span><span class="p">(</span><span class="nv">$old_encrypted_string</span><span class="p">);</span> +</pre></div> +</div> +<table border="1" class="docutils"> +<colgroup> +<col width="20%" /> +<col width="14%" /> +<col width="66%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Parameter</th> +<th class="head">Default</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>$orig_data</strong></td> +<td>n/a</td> +<td>The original encrypted data from CodeIgniter 1.x’s Encryption library</td> +</tr> +<tr class="row-odd"><td><strong>$legacy_mode</strong></td> +<td>MCRYPT_MODE_ECB</td> +<td>The Mcrypt mode that was used to generate the original encrypted data. +CodeIgniter 1.x’s default was MCRYPT_MODE_ECB, and it will assume that +to be the case unless overridden by this parameter.</td> +</tr> +<tr class="row-even"><td><strong>$key</strong></td> +<td>n/a</td> +<td>The encryption key. This it typically specified in your config file as +outlined above.</td> +</tr> +</tbody> +</table> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="encryption.html" class="btn btn-neutral float-right" title="Encryption Library">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="email.html" class="btn btn-neutral" title="Email Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/encryption.html b/user_guide/libraries/encryption.html new file mode 100644 index 000000000..8a8d4fd39 --- /dev/null +++ b/user_guide/libraries/encryption.html @@ -0,0 +1,1405 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Encryption Library — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="File Uploading Class" href="file_uploading.html"/> + <link rel="prev" title="Encrypt Class" href="encrypt.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Encryption Library</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="encryption-library"> +<h1>Encryption Library<a class="headerlink" href="#encryption-library" title="Permalink to this headline">¶</a></h1> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">DO NOT use this or any other <em>encryption</em> library for +user password storage! Passwords must be <em>hashed</em> instead, and you +should do that via PHP’s own <a class="reference external" href="http://php.net/password">Password Hashing extension</a>.</p> +</div> +<p>The Encryption Library provides two-way data encryption. To do so in +a cryptographically secure way, it utilizes PHP extensions that are +unfortunately not always available on all systems. +You must meet one of the following dependencies in order to use this +library:</p> +<ul class="simple"> +<li><a class="reference external" href="http://php.net/openssl">OpenSSL</a></li> +<li><a class="reference external" href="http://php.net/mcrypt">MCrypt</a> (and <cite>MCRYPT_DEV_URANDOM</cite> availability)</li> +</ul> +<p>If neither of the above dependencies is met, we simply cannot offer +you a good enough implementation to meet the high standards required +for proper cryptography.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-encryption-library" id="id2">Using the Encryption Library</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id3">Initializing the Class</a></li> +<li><a class="reference internal" href="#default-behavior" id="id4">Default behavior</a></li> +<li><a class="reference internal" href="#setting-your-encryption-key" id="id5">Setting your encryption_key</a></li> +<li><a class="reference internal" href="#supported-encryption-ciphers-and-modes" id="id6">Supported encryption ciphers and modes</a><ul> +<li><a class="reference internal" href="#portable-ciphers" id="id7">Portable ciphers</a></li> +<li><a class="reference internal" href="#driver-specific-ciphers" id="id8">Driver-specific ciphers</a></li> +<li><a class="reference internal" href="#encryption-modes" id="id9">Encryption modes</a></li> +</ul> +</li> +<li><a class="reference internal" href="#message-length" id="id10">Message Length</a></li> +<li><a class="reference internal" href="#configuring-the-library" id="id11">Configuring the library</a></li> +<li><a class="reference internal" href="#encrypting-and-decrypting-data" id="id12">Encrypting and decrypting data</a><ul> +<li><a class="reference internal" href="#how-it-works" id="id13">How it works</a></li> +<li><a class="reference internal" href="#using-custom-parameters" id="id14">Using custom parameters</a></li> +<li><a class="reference internal" href="#supported-hmac-authentication-algorithms" id="id15">Supported HMAC authentication algorithms</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id16">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-encryption-library"> +<h2><a class="toc-backref" href="#id2">Using the Encryption Library</a><a class="headerlink" href="#using-the-encryption-library" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id3">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Encryption library is +initialized in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> +method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'encryption'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Encryption library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span> +</pre></div> +</div> +</div> +<div class="section" id="default-behavior"> +<h3><a class="toc-backref" href="#id4">Default behavior</a><a class="headerlink" href="#default-behavior" title="Permalink to this headline">¶</a></h3> +<p>By default, the Encryption Library will use the AES-128 cipher in CBC +mode, using your configured <em>encryption_key</em> and SHA512 HMAC authentication.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">AES-128 is chosen both because it is proven to be strong and +because of its wide availability across different cryptographic +software and programming languages’ APIs.</p> +</div> +<p>However, the <em>encryption_key</em> is not used as is.</p> +<p>If you are somewhat familiar with cryptography, you should already know +that a HMAC also requires a secret key and using the same key for both +encryption and authentication is a bad practice.</p> +<p>Because of that, two separate keys are derived from your already configured +<em>encryption_key</em>: one for encryption and one for authentication. This is +done via a technique called <a class="reference external" href="http://en.wikipedia.org/wiki/HKDF">HMAC-based Key Derivation Function</a> (HKDF).</p> +</div> +<div class="section" id="setting-your-encryption-key"> +<h3><a class="toc-backref" href="#id5">Setting your encryption_key</a><a class="headerlink" href="#setting-your-encryption-key" title="Permalink to this headline">¶</a></h3> +<p>An <em>encryption key</em> is a piece of information that controls the +cryptographic process and permits a plain-text string to be encrypted, +and afterwards - decrypted. It is the secret “ingredient” in the whole +process that allows you to be the only one who is able to decrypt data +that you’ve decided to hide from the eyes of the public. +After one key is used to encrypt data, that same key provides the <strong>only</strong> +means to decrypt it, so not only must you chose one carefully, but you +must not lose it or you will also lose access to the data.</p> +<p>It must be noted that to ensure maximum security, such key <em>should</em> not +only be as strong as possible, but also often changed. Such behavior +however is rarely practical or possible to implement, and that is why +CodeIgniter gives you the ability to configure a single key that is to be +used (almost) every time.</p> +<p>It goes without saying that you should guard your key carefully. Should +someone gain access to your key, the data will be easily decrypted. If +your server is not totally under your control it’s impossible to ensure +key security so you may want to think carefully before using it for +anything that requires high security, like storing credit card numbers.</p> +<p>Your encryption key <strong>must</strong> be as long as the encyption algorithm in use +allows. For AES-128, that’s 128 bits or 16 bytes (charcters) long. +You will find a table below that shows the supported key lengths of +different ciphers.</p> +<p>The key should be as random as possible and it <strong>must not</strong> be a regular +text string, nor the output of a hashing function, etc. In order to create +a proper key, you must use the Encryption library’s <code class="docutils literal"><span class="pre">create_key()</span></code> method</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// $key will be assigned a 16-byte (128-bit) random key</span> +<span class="nv">$key</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">create_key</span><span class="p">(</span><span class="mi">16</span><span class="p">);</span> +</pre></div> +</div> +<p>The key can be either stored in your <em>application/config/config.php</em>, or +you can design your own storage mechanism and pass the key dynamically +when encrypting/decrypting.</p> +<p>To save your key to your <em>application/config/config.php</em>, open the file +and set:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'encryption_key'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'YOUR KEY'</span><span class="p">;</span> +</pre></div> +</div> +<p>You’ll notice that the <code class="docutils literal"><span class="pre">create_key()</span></code> method outputs binary data, which +is hard to deal with (i.e. a copy-paste may damage it), so you may use +<code class="docutils literal"><span class="pre">bin2hex()</span></code>, <code class="docutils literal"><span class="pre">hex2bin()</span></code> or Base64-encoding to work with the key in +a more friendly manner. For example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Get a hex-encoded representation of the key:</span> +<span class="nv">$key</span> <span class="o">=</span> <span class="nb">bin2hex</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">create_key</span><span class="p">(</span><span class="mi">16</span><span class="p">));</span> + +<span class="c1">// Put the same value in your config with hex2bin(),</span> +<span class="c1">// so that it is still passed as binary to the library:</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'encryption_key'</span><span class="p">]</span> <span class="o">=</span> <span class="nb">hex2bin</span><span class="p">(</span><span class="o"><</span><span class="nx">your</span> <span class="nx">hex</span><span class="o">-</span><span class="nx">encoded</span> <span class="nb">key</span><span class="o">></span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="supported-encryption-ciphers-and-modes"> +<span id="ciphers-and-modes"></span><h3><a class="toc-backref" href="#id6">Supported encryption ciphers and modes</a><a class="headerlink" href="#supported-encryption-ciphers-and-modes" title="Permalink to this headline">¶</a></h3> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The terms ‘cipher’ and ‘encryption algorithm’ are interchangeable.</p> +</div> +<div class="section" id="portable-ciphers"> +<h4><a class="toc-backref" href="#id7">Portable ciphers</a><a class="headerlink" href="#portable-ciphers" title="Permalink to this headline">¶</a></h4> +<p>Because MCrypt and OpenSSL (also called drivers throughout this document) +each support different sets of encryption algorithms and often implement +them in different ways, our Encryption library is designed to use them in +a portable fashion, or in other words - it enables you to use them +interchangeably, at least for the ciphers supported by both drivers.</p> +<p>It is also implemented in a way that aims to match the standard +implementations in other programming languages and libraries.</p> +<p>Here’s a list of the so called “portable” ciphers, where +“CodeIgniter name” is the string value that you’d have to pass to the +Encryption library to use that cipher:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="24%" /> +<col width="18%" /> +<col width="28%" /> +<col width="31%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Cipher name</th> +<th class="head">CodeIgniter name</th> +<th class="head">Key lengths (bits / bytes)</th> +<th class="head">Supported modes</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>AES-128 / Rijndael-128</td> +<td>aes-128</td> +<td>128 / 16</td> +<td>CBC, CTR, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-odd"><td>AES-192</td> +<td>aes-192</td> +<td>192 / 24</td> +<td>CBC, CTR, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-even"><td>AES-256</td> +<td>aes-256</td> +<td>256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-odd"><td>DES</td> +<td>des</td> +<td>56 / 7</td> +<td>CBC, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-even"><td>TripleDES</td> +<td>tripledes</td> +<td>56 / 7, 112 / 14, 168 / 21</td> +<td>CBC, CFB, CFB8, OFB</td> +</tr> +<tr class="row-odd"><td>Blowfish</td> +<td>blowfish</td> +<td>128-448 / 16-56</td> +<td>CBC, CFB, OFB, ECB</td> +</tr> +<tr class="row-even"><td>CAST5 / CAST-128</td> +<td>cast5</td> +<td>88-128 / 11-16</td> +<td>CBC, CFB, OFB, ECB</td> +</tr> +<tr class="row-odd"><td>RC4 / ARCFour</td> +<td>rc4</td> +<td>40-2048 / 5-256</td> +<td>Stream</td> +</tr> +</tbody> +</table> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Because of how MCrypt works, if you fail to provide a key +with the appropriate length, you might end up using a different +algorithm than the one configured, so be really careful with that!</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In case it isn’t clear from the above table, Blowfish, CAST5 +and RC4 support variable length keys. That is, any number in the +shown ranges is valid, although in bit terms that only happens +in 8-bit increments.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Even though CAST5 supports key lengths lower than 128 bits +(16 bytes), in fact they will just be zero-padded to the +maximum length, as specified in <a class="reference external" href="http://tools.ietf.org/rfc/rfc2144.txt">RFC 2144</a>.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Blowfish supports key lengths as small as 32 bits (4 bytes), but +our tests have shown that only lengths of 128 bits (16 bytes) or +higher are properly supported by both MCrypt and OpenSSL. It is +also a bad practice to use such low-length keys anyway.</p> +</div> +</div> +<div class="section" id="driver-specific-ciphers"> +<h4><a class="toc-backref" href="#id8">Driver-specific ciphers</a><a class="headerlink" href="#driver-specific-ciphers" title="Permalink to this headline">¶</a></h4> +<p>As noted above, MCrypt and OpenSSL support different sets of encryption +ciphers. For portability reasons and because we haven’t tested them +properly, we do not advise you to use the ones that are driver-specific, +but regardless, here’s a list of most of them:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="15%" /> +<col width="10%" /> +<col width="32%" /> +<col width="44%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Cipher name</th> +<th class="head">Driver</th> +<th class="head">Key lengths (bits / bytes)</th> +<th class="head">Supported modes</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>AES-128</td> +<td>OpenSSL</td> +<td>128 / 16</td> +<td>CBC, CTR, CFB, CFB8, OFB, ECB, XTS</td> +</tr> +<tr class="row-odd"><td>AES-192</td> +<td>OpenSSL</td> +<td>192 / 24</td> +<td>CBC, CTR, CFB, CFB8, OFB, ECB, XTS</td> +</tr> +<tr class="row-even"><td>AES-256</td> +<td>OpenSSL</td> +<td>256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, ECB, XTS</td> +</tr> +<tr class="row-odd"><td>Rijndael-128</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-even"><td>Rijndael-192</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-odd"><td>Rijndael-256</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-even"><td>GOST</td> +<td>MCrypt</td> +<td>256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-odd"><td>Twofish</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-even"><td>CAST-128</td> +<td>MCrypt</td> +<td>40-128 / 5-16</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-odd"><td>CAST-256</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-even"><td>Loki97</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-odd"><td>SaferPlus</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-even"><td>Serpent</td> +<td>MCrypt</td> +<td>128 / 16, 192 / 24, 256 / 32</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-odd"><td>XTEA</td> +<td>MCrypt</td> +<td>128 / 16</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-even"><td>RC2</td> +<td>MCrypt</td> +<td>8-1024 / 1-128</td> +<td>CBC, CTR, CFB, CFB8, OFB, OFB8, ECB</td> +</tr> +<tr class="row-odd"><td>RC2</td> +<td>OpenSSL</td> +<td>8-1024 / 1-128</td> +<td>CBC, CFB, OFB, ECB</td> +</tr> +<tr class="row-even"><td>Camellia-128</td> +<td>OpenSSL</td> +<td>128 / 16</td> +<td>CBC, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-odd"><td>Camellia-192</td> +<td>OpenSSL</td> +<td>192 / 24</td> +<td>CBC, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-even"><td>Camellia-256</td> +<td>OpenSSL</td> +<td>256 / 32</td> +<td>CBC, CFB, CFB8, OFB, ECB</td> +</tr> +<tr class="row-odd"><td>Seed</td> +<td>OpenSSL</td> +<td>128 / 16</td> +<td>CBC, CFB, OFB, ECB</td> +</tr> +</tbody> +</table> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If you wish to use one of those ciphers, you’d have to pass +its name in lower-case to the Encryption library.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You’ve probably noticed that all AES cipers (and Rijndael-128) +are also listed in the portable ciphers list. This is because +drivers support different modes for these ciphers. Also, it is +important to note that AES-128 and Rijndael-128 are actually +the same cipher, but <strong>only</strong> when used with a 128-bit key.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">CAST-128 / CAST-5 is also listed in both the portable and +driver-specific ciphers list. This is because OpenSSL’s +implementation doesn’t appear to be working correctly with +key sizes of 80 bits and lower.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">RC2 is listed as supported by both MCrypt and OpenSSL. +However, both drivers implement them differently and they +are not portable. It is probably worth noting that we only +found one obscure source confirming that it is MCrypt that +is not properly implementing it.</p> +</div> +</div> +<div class="section" id="encryption-modes"> +<span id="id1"></span><h4><a class="toc-backref" href="#id9">Encryption modes</a><a class="headerlink" href="#encryption-modes" title="Permalink to this headline">¶</a></h4> +<p>Different modes of encryption have different characteristics and serve +for different purposes. Some are stronger than others, some are faster +and some offer extra features. +We are not going in depth into that here, we’ll leave that to the +cryptography experts. The table below is to provide brief informational +reference to our more experienced users. If you are a beginner, just +stick to the CBC mode - it is widely accepted as strong and secure for +general purposes.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="6%" /> +<col width="9%" /> +<col width="9%" /> +<col width="76%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Mode name</th> +<th class="head">CodeIgniter name</th> +<th class="head">Driver support</th> +<th class="head">Additional info</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>CBC</td> +<td>cbc</td> +<td>MCrypt, OpenSSL</td> +<td>A safe default choice</td> +</tr> +<tr class="row-odd"><td>CTR</td> +<td>ctr</td> +<td>MCrypt, OpenSSL</td> +<td>Considered as theoretically better than CBC, but not as widely available</td> +</tr> +<tr class="row-even"><td>CFB</td> +<td>cfb</td> +<td>MCrypt, OpenSSL</td> +<td>N/A</td> +</tr> +<tr class="row-odd"><td>CFB8</td> +<td>cfb8</td> +<td>MCrypt, OpenSSL</td> +<td>Same as CFB, but operates in 8-bit mode (not recommended).</td> +</tr> +<tr class="row-even"><td>OFB</td> +<td>ofb</td> +<td>MCrypt, OpenSSL</td> +<td>N/A</td> +</tr> +<tr class="row-odd"><td>OFB8</td> +<td>ofb8</td> +<td>MCrypt</td> +<td>Same as OFB, but operates in 8-bit mode (not recommended).</td> +</tr> +<tr class="row-even"><td>ECB</td> +<td>ecb</td> +<td>MCrypt, OpenSSL</td> +<td>Ignores IV (not recommended).</td> +</tr> +<tr class="row-odd"><td>XTS</td> +<td>xts</td> +<td>OpenSSL</td> +<td>Usually used for encrypting random access data such as RAM or hard-disk storage.</td> +</tr> +<tr class="row-even"><td>Stream</td> +<td>stream</td> +<td>MCrypt, OpenSSL</td> +<td>This is not actually a mode, it just says that a stream cipher is being used. Required because of the general cipher+mode initialization process.</td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="section" id="message-length"> +<h3><a class="toc-backref" href="#id10">Message Length</a><a class="headerlink" href="#message-length" title="Permalink to this headline">¶</a></h3> +<p>It’s probably important for you to know that an encrypted string is usually +longer than the original, plain-text string (depending on the cipher).</p> +<p>This is influenced by the cipher algorithm itself, the IV prepended to the +cipher-text and the HMAC authentication message that is also prepended. +Furthermore, the encrypted message is also Base64-encoded so that it is safe +for storage and transmission, regardless of a possible character set in use.</p> +<p>Keep this information in mind when selecting your data storage mechanism. +Cookies, for example, can only hold 4K of information.</p> +</div> +<div class="section" id="configuring-the-library"> +<span id="configuration"></span><h3><a class="toc-backref" href="#id11">Configuring the library</a><a class="headerlink" href="#configuring-the-library" title="Permalink to this headline">¶</a></h3> +<p>For usability, performance, but also historical reasons tied to our old +<a class="reference internal" href="encrypt.html"><span class="doc">Encrypt Class</span></a>, the Encryption library is designed to +use repeatedly the same driver, encryption cipher, mode and key.</p> +<p>As noted in the “Default behavior” section above, this means using an +auto-detected driver (OpenSSL has a higher priority), the AES-128 ciper +in CBC mode, and your <code class="docutils literal"><span class="pre">$config['encryption_key']</span></code> value.</p> +<p>If you wish to change that however, you need to use the <code class="docutils literal"><span class="pre">initialize()</span></code> +method. It accepts an associative array of parameters, all of which are +optional:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="15%" /> +<col width="85%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Option</th> +<th class="head">Possible values</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>driver</td> +<td>‘mcrypt’, ‘openssl’</td> +</tr> +<tr class="row-odd"><td>cipher</td> +<td>Cipher name (see <a class="reference internal" href="#ciphers-and-modes"><span class="std std-ref">Supported encryption ciphers and modes</span></a>)</td> +</tr> +<tr class="row-even"><td>mode</td> +<td>Encryption mode (see <a class="reference internal" href="#encryption-modes"><span class="std std-ref">Encryption modes</span></a>)</td> +</tr> +<tr class="row-odd"><td>key</td> +<td>Encryption key</td> +</tr> +</tbody> +</table> +<p>For example, if you were to change the encryption algorithm and +mode to AES-256 in CTR mode, this is what you should do:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'cipher'</span> <span class="o">=></span> <span class="s1">'aes-256'</span><span class="p">,</span> + <span class="s1">'mode'</span> <span class="o">=></span> <span class="s1">'ctr'</span><span class="p">,</span> + <span class="s1">'key'</span> <span class="o">=></span> <span class="s1">'<a 32-character random string>'</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Note that we only mentioned that you want to change the ciper and mode, +but we also included a key in the example. As previously noted, it is +important that you choose a key with a proper size for the used algorithm.</p> +<p>There’s also the ability to change the driver, if for some reason you +have both, but want to use MCrypt instead of OpenSSL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Switch to the MCrypt driver</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'driver'</span> <span class="o">=></span> <span class="s1">'mcrypt'</span><span class="p">));</span> + +<span class="c1">// Switch back to the OpenSSL driver</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'driver'</span> <span class="o">=></span> <span class="s1">'openssl'</span><span class="p">));</span> +</pre></div> +</div> +</div> +<div class="section" id="encrypting-and-decrypting-data"> +<h3><a class="toc-backref" href="#id12">Encrypting and decrypting data</a><a class="headerlink" href="#encrypting-and-decrypting-data" title="Permalink to this headline">¶</a></h3> +<p>Encrypting and decrypting data with the already configured library +settings is simple. As simple as just passing the string to the +<code class="docutils literal"><span class="pre">encrypt()</span></code> and/or <code class="docutils literal"><span class="pre">decrypt()</span></code> methods:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$plain_text</span> <span class="o">=</span> <span class="s1">'This is a plain-text message!'</span><span class="p">;</span> +<span class="nv">$ciphertext</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">encrypt</span><span class="p">(</span><span class="nv">$plain_text</span><span class="p">);</span> + +<span class="c1">// Outputs: This is a plain-text message!</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">decrypt</span><span class="p">(</span><span class="nv">$ciphertext</span><span class="p">);</span> +</pre></div> +</div> +<p>And that’s it! The Encryption library will do everything necessary +for the whole process to be cryptographically secure out-of-the-box. +You don’t need to worry about it.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Both methods will return FALSE in case of an error. +While for <code class="docutils literal"><span class="pre">encrypt()</span></code> this can only mean incorrect +configuration, you should always check the return value +of <code class="docutils literal"><span class="pre">decrypt()</span></code> in production code.</p> +</div> +<div class="section" id="how-it-works"> +<h4><a class="toc-backref" href="#id13">How it works</a><a class="headerlink" href="#how-it-works" title="Permalink to this headline">¶</a></h4> +<p>If you must know how the process works, here’s what happens under +the hood:</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">$this->encryption->encrypt($plain_text)</span></code><ol class="arabic"> +<li>Derive an encryption key and a HMAC key from your configured +<em>encryption_key</em> via HKDF, using the SHA-512 digest algorithm.</li> +<li>Generate a random initialization vector (IV).</li> +<li>Encrypt the data via AES-128 in CBC mode (or another previously +configured cipher and mode), using the above-mentioned derived +encryption key and IV.</li> +<li>Prepend said IV to the resulting cipher-text.</li> +<li>Base64-encode the resulting string, so that it can be safely +stored or transferred without worrying about character sets.</li> +<li>Create a SHA-512 HMAC authentication message using the derived +HMAC key to ensure data integrity and prepend it to the Base64 +string.</li> +</ol> +</li> +<li><code class="docutils literal"><span class="pre">$this->encryption->decrypt($ciphertext)</span></code><ol class="arabic"> +<li>Derive an encryption key and a HMAC key from your configured +<em>encryption_key</em> via HKDF, using the SHA-512 digest algorithm. +Because your configured <em>encryption_key</em> is the same, this +will produce the same result as in the <code class="docutils literal"><span class="pre">encrypt()</span></code> method +above - otherwise you won’t be able to decrypt it.</li> +<li>Check if the string is long enough, separate the HMAC out of +it and validate if it is correct (this is done in a way that +prevents timing attacks against it). Return FALSE if either of +the checks fails.</li> +<li>Base64-decode the string.</li> +<li>Separate the IV out of the cipher-text and decrypt the said +cipher-text using that IV and the derived encryption key.</li> +</ol> +</li> +</ul> +</div> +<div class="section" id="using-custom-parameters"> +<span id="custom-parameters"></span><h4><a class="toc-backref" href="#id14">Using custom parameters</a><a class="headerlink" href="#using-custom-parameters" title="Permalink to this headline">¶</a></h4> +<p>Let’s say you have to interact with another system that is out +of your control and uses another method to encrypt data. A +method that will most certainly not match the above-described +sequence and probably not use all of the steps either.</p> +<p>The Encryption library allows you to change how its encryption +and decryption processes work, so that you can easily tailor a +custom solution for such situations.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">It is possible to use the library in this way, without +setting an <em>encryption_key</em> in your configuration file.</p> +</div> +<p>All you have to do is to pass an associative array with a few +parameters to either the <code class="docutils literal"><span class="pre">encrypt()</span></code> or <code class="docutils literal"><span class="pre">decrypt()</span></code> method. +Here’s an example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Assume that we have $ciphertext, $key and $hmac_key</span> +<span class="c1">// from on outside source</span> + +<span class="nv">$message</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">decrypt</span><span class="p">(</span> + <span class="nv">$ciphertext</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'cipher'</span> <span class="o">=></span> <span class="s1">'blowfish'</span><span class="p">,</span> + <span class="s1">'mode'</span> <span class="o">=></span> <span class="s1">'cbc'</span><span class="p">,</span> + <span class="s1">'key'</span> <span class="o">=></span> <span class="nv">$key</span><span class="p">,</span> + <span class="s1">'hmac_digest'</span> <span class="o">=></span> <span class="s1">'sha256'</span><span class="p">,</span> + <span class="s1">'hmac_key'</span> <span class="o">=></span> <span class="nv">$hmac_key</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>In the above example, we are decrypting a message that was encrypted +using the Blowfish cipher in CBC mode and authenticated via a SHA-256 +HMAC.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Note that both ‘key’ and ‘hmac_key’ are used in this +example. When using custom parameters, encryption and HMAC keys +are not derived like the default behavior of the library is.</p> +</div> +<p>Below is a list of the available options.</p> +<p>However, unless you really need to and you know what you are doing, +we advise you to not change the encryption process as this could +impact security, so please do so with caution.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="12%" /> +<col width="14%" /> +<col width="26%" /> +<col width="49%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Option</th> +<th class="head">Default value</th> +<th class="head">Mandatory / Optional</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>cipher</td> +<td>N/A</td> +<td>Yes</td> +<td>Encryption algorithm (see <a class="reference internal" href="#ciphers-and-modes"><span class="std std-ref">Supported encryption ciphers and modes</span></a>).</td> +</tr> +<tr class="row-odd"><td>mode</td> +<td>N/A</td> +<td>Yes</td> +<td>Encryption mode (see <a class="reference internal" href="#encryption-modes"><span class="std std-ref">Encryption modes</span></a>).</td> +</tr> +<tr class="row-even"><td>key</td> +<td>N/A</td> +<td>Yes</td> +<td>Encryption key.</td> +</tr> +<tr class="row-odd"><td>hmac</td> +<td>TRUE</td> +<td>No</td> +<td>Whether to use a HMAC. +Boolean. If set to FALSE, then <em>hmac_digest</em> and +<em>hmac_key</em> will be ignored.</td> +</tr> +<tr class="row-even"><td>hmac_digest</td> +<td>sha512</td> +<td>No</td> +<td>HMAC message digest algorithm (see <a class="reference internal" href="#digests"><span class="std std-ref">Supported HMAC authentication algorithms</span></a>).</td> +</tr> +<tr class="row-odd"><td>hmac_key</td> +<td>N/A</td> +<td>Yes, unless <em>hmac</em> is FALSE</td> +<td>HMAC key.</td> +</tr> +<tr class="row-even"><td>raw_data</td> +<td>FALSE</td> +<td>No</td> +<td>Whether the cipher-text should be raw. +Boolean. If set to TRUE, then Base64 encoding and +decoding will not be performed and HMAC will not +be a hexadecimal string.</td> +</tr> +</tbody> +</table> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last"><code class="docutils literal"><span class="pre">encrypt()</span></code> and <code class="docutils literal"><span class="pre">decrypt()</span></code> will return FALSE if +a mandatory parameter is not provided or if a provided +value is incorrect. This includes <em>hmac_key</em>, unless <em>hmac</em> +is set to FALSE.</p> +</div> +</div> +<div class="section" id="supported-hmac-authentication-algorithms"> +<span id="digests"></span><h4><a class="toc-backref" href="#id15">Supported HMAC authentication algorithms</a><a class="headerlink" href="#supported-hmac-authentication-algorithms" title="Permalink to this headline">¶</a></h4> +<p>For HMAC message authentication, the Encryption library supports +usage of the SHA-2 family of algorithms:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="19%" /> +<col width="34%" /> +<col width="47%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Algorithm</th> +<th class="head">Raw length (bytes)</th> +<th class="head">Hex-encoded length (bytes)</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>sha512</td> +<td>64</td> +<td>128</td> +</tr> +<tr class="row-odd"><td>sha384</td> +<td>48</td> +<td>96</td> +</tr> +<tr class="row-even"><td>sha256</td> +<td>32</td> +<td>64</td> +</tr> +<tr class="row-odd"><td>sha224</td> +<td>28</td> +<td>56</td> +</tr> +</tbody> +</table> +<p>The reason for not including other popular algorithms, such as +MD5 or SHA1 is that they are no longer considered secure enough +and as such, we don’t want to encourage their usage. +If you absolutely need to use them, it is easy to do so via PHP’s +native <a class="reference external" href="http://php.net/manual/en/function.hash-hmac.php">hash_hmac()</a> function.</p> +<p>Stronger algorithms of course will be added in the future as they +appear and become widely available.</p> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id16">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Encryption"> +<em class="property">class </em><code class="descname">CI_Encryption</code><a class="headerlink" href="#CI_Encryption" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Encryption::initialize"> +<code class="descname">initialize</code><span class="sig-paren">(</span><em>$params</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encryption::initialize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$params</strong> (<em>array</em>) – Configuration parameters</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Encryption instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Encryption</p> +</td> +</tr> +</tbody> +</table> +<p>Initializes (configures) the library to use a different +driver, cipher, mode or key.</p> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'mode'</span> <span class="o">=></span> <span class="s1">'ctr'</span><span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Please refer to the <a class="reference internal" href="#configuration"><span class="std std-ref">Configuring the library</span></a> section for detailed info.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encryption::encrypt"> +<code class="descname">encrypt</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$params = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encryption::encrypt" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>string</em>) – Data to encrypt</li> +<li><strong>$params</strong> (<em>array</em>) – Optional parameters</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Encrypted data or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Encrypts the input data and returns its ciphertext.</p> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$ciphertext</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">encrypt</span><span class="p">(</span><span class="s1">'My secret message'</span><span class="p">);</span> +</pre></div> +</div> +<p>Please refer to the <a class="reference internal" href="#custom-parameters"><span class="std std-ref">Using custom parameters</span></a> section for information +on the optional parameters.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encryption::decrypt"> +<code class="descname">decrypt</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$params = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encryption::decrypt" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>string</em>) – Data to decrypt</li> +<li><strong>$params</strong> (<em>array</em>) – Optional parameters</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Decrypted data or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Decrypts the input data and returns it in plain-text.</p> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">decrypt</span><span class="p">(</span><span class="nv">$ciphertext</span><span class="p">);</span> +</pre></div> +</div> +<p>Please refer to the <a class="reference internal" href="#custom-parameters"><span class="std std-ref">Using custom parameters</span></a> secrion for information +on the optional parameters.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encryption::create_key"> +<code class="descname">create_key</code><span class="sig-paren">(</span><em>$length</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encryption::create_key" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$length</strong> (<em>int</em>) – Output length</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A pseudo-random cryptographic key with the specified length, or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Creates a cryptographic key by fetching random data from +the operating system’s sources (i.e. /dev/urandom).</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Encryption::hkdf"> +<code class="descname">hkdf</code><span class="sig-paren">(</span><em>$key</em><span class="optional">[</span>, <em>$digest = 'sha512'</em><span class="optional">[</span>, <em>$salt = NULL</em><span class="optional">[</span>, <em>$length = NULL</em><span class="optional">[</span>, <em>$info = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Encryption::hkdf" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Input key material</li> +<li><strong>$digest</strong> (<em>string</em>) – A SHA-2 family digest algorithm</li> +<li><strong>$salt</strong> (<em>string</em>) – Optional salt</li> +<li><strong>$length</strong> (<em>int</em>) – Optional output length</li> +<li><strong>$info</strong> (<em>string</em>) – Optional context/application-specific info</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A pseudo-random key or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Derives a key from another, presumably weaker key.</p> +<p>This method is used internally to derive an encryption and HMAC key +from your configured <em>encryption_key</em>.</p> +<p>It is publicly available due to its otherwise general purpose. It is +described in <a class="reference external" href="https://tools.ietf.org/rfc/rfc5869.txt">RFC 5869</a>.</p> +<p>However, as opposed to the description in RFC 5869, this implementation +doesn’t support SHA1.</p> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$hmac_key</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">encryption</span><span class="o">-></span><span class="na">hkdf</span><span class="p">(</span> + <span class="nv">$key</span><span class="p">,</span> + <span class="s1">'sha512'</span><span class="p">,</span> + <span class="k">NULL</span><span class="p">,</span> + <span class="k">NULL</span><span class="p">,</span> + <span class="s1">'authentication'</span> +<span class="p">);</span> + +<span class="c1">// $hmac_key is a pseudo-random key with a length of 64 bytes</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="file_uploading.html" class="btn btn-neutral float-right" title="File Uploading Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="encrypt.html" class="btn btn-neutral" title="Encrypt Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html new file mode 100644 index 000000000..eda808451 --- /dev/null +++ b/user_guide/libraries/file_uploading.html @@ -0,0 +1,1025 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>File Uploading Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Form Validation" href="form_validation.html"/> + <link rel="prev" title="Encryption Library" href="encryption.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>File Uploading Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="file-uploading-class"> +<h1>File Uploading Class<a class="headerlink" href="#file-uploading-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s File Uploading Class permits files to be uploaded. You can +set various preferences, restricting the type and size of the files.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#the-process" id="id1">The Process</a><ul> +<li><a class="reference internal" href="#creating-the-upload-form" id="id2">Creating the Upload Form</a></li> +<li><a class="reference internal" href="#the-success-page" id="id3">The Success Page</a></li> +<li><a class="reference internal" href="#the-controller" id="id4">The Controller</a></li> +<li><a class="reference internal" href="#the-upload-directory" id="id5">The Upload Directory</a></li> +<li><a class="reference internal" href="#try-it" id="id6">Try it!</a></li> +</ul> +</li> +<li><a class="reference internal" href="#reference-guide" id="id7">Reference Guide</a><ul> +<li><a class="reference internal" href="#initializing-the-upload-class" id="id8">Initializing the Upload Class</a></li> +<li><a class="reference internal" href="#setting-preferences" id="id9">Setting Preferences</a></li> +<li><a class="reference internal" href="#preferences" id="id10">Preferences</a></li> +<li><a class="reference internal" href="#setting-preferences-in-a-config-file" id="id11">Setting preferences in a config file</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id12">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="the-process"> +<h2><a class="toc-backref" href="#id1">The Process</a><a class="headerlink" href="#the-process" title="Permalink to this headline">¶</a></h2> +<p>Uploading a file involves the following general process:</p> +<ul class="simple"> +<li>An upload form is displayed, allowing a user to select a file and +upload it.</li> +<li>When the form is submitted, the file is uploaded to the destination +you specify.</li> +<li>Along the way, the file is validated to make sure it is allowed to be +uploaded based on the preferences you set.</li> +<li>Once uploaded, the user will be shown a success message.</li> +</ul> +<p>To demonstrate this process here is brief tutorial. Afterward you’ll +find reference information.</p> +<div class="section" id="creating-the-upload-form"> +<h3><a class="toc-backref" href="#id2">Creating the Upload Form</a><a class="headerlink" href="#creating-the-upload-form" title="Permalink to this headline">¶</a></h3> +<p>Using a text editor, create a form called upload_form.php. In it, place +this code and save it to your <strong>application/views/</strong> directory:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> +<span class="o"><</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="nx">Upload</span> <span class="nx">Form</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> +<span class="o"></</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">body</span><span class="o">></span> + +<span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nv">$error</span><span class="p">;</span><span class="cp">?></span> + +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_open_multipart</span><span class="p">(</span><span class="s1">'upload/do_upload'</span><span class="p">);</span><span class="cp">?></span> + +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"file"</span> <span class="na">name</span><span class="o">=</span><span class="s">"userfile"</span> <span class="na">size</span><span class="o">=</span><span class="s">"20"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">br</span> <span class="p">/><</span><span class="nt">br</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"submit"</span> <span class="na">value</span><span class="o">=</span><span class="s">"upload"</span> <span class="p">/></span> + +<span class="p"></</span><span class="nt">form</span><span class="p">></span> + +<span class="p"></</span><span class="nt">body</span><span class="p">></span> +<span class="p"></</span><span class="nt">html</span><span class="p">></span> +</pre></div> +</div> +<p>You’ll notice we are using a form helper to create the opening form tag. +File uploads require a multipart form, so the helper creates the proper +syntax for you. You’ll also notice we have an $error variable. This is +so we can show error messages in the event the user does something +wrong.</p> +</div> +<div class="section" id="the-success-page"> +<h3><a class="toc-backref" href="#id3">The Success Page</a><a class="headerlink" href="#the-success-page" title="Permalink to this headline">¶</a></h3> +<p>Using a text editor, create a form called upload_success.php. In it, +place this code and save it to your <strong>application/views/</strong> directory:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> +<span class="o"><</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="nx">Upload</span> <span class="nx">Form</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> +<span class="o"></</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">body</span><span class="o">></span> + +<span class="o"><</span><span class="nx">h3</span><span class="o">></span><span class="nx">Your</span> <span class="nb">file</span> <span class="nx">was</span> <span class="nx">successfully</span> <span class="nx">uploaded</span><span class="o">!</</span><span class="nx">h3</span><span class="o">></span> + +<span class="o"><</span><span class="nx">ul</span><span class="o">></span> +<span class="o"><?</span><span class="nx">php</span> <span class="k">foreach</span> <span class="p">(</span><span class="nv">$upload_data</span> <span class="k">as</span> <span class="nv">$item</span> <span class="o">=></span> <span class="nv">$value</span><span class="p">)</span><span class="o">:</span><span class="cp">?></span> +<span class="p"><</span><span class="nt">li</span><span class="p">></span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$item</span><span class="p">;</span><span class="cp">?></span>: <span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$value</span><span class="p">;</span><span class="cp">?></span><span class="p"></</span><span class="nt">li</span><span class="p">></span> +<span class="cp"><?php</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?></span> +<span class="p"></</span><span class="nt">ul</span><span class="p">></span> + +<span class="p"><</span><span class="nt">p</span><span class="p">></span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">anchor</span><span class="p">(</span><span class="s1">'upload'</span><span class="p">,</span> <span class="s1">'Upload Another File!'</span><span class="p">);</span> <span class="cp">?></span><span class="p"></</span><span class="nt">p</span><span class="p">></span> + +<span class="p"></</span><span class="nt">body</span><span class="p">></span> +<span class="p"></</span><span class="nt">html</span><span class="p">></span> +</pre></div> +</div> +</div> +<div class="section" id="the-controller"> +<h3><a class="toc-backref" href="#id4">The Controller</a><a class="headerlink" href="#the-controller" title="Permalink to this headline">¶</a></h3> +<p>Using a text editor, create a controller called Upload.php. In it, place +this code and save it to your <strong>application/controllers/</strong> directory:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Upload</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">__construct</span><span class="p">()</span> + <span class="p">{</span> + <span class="k">parent</span><span class="o">::</span><span class="na">__construct</span><span class="p">();</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">helper</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'form'</span><span class="p">,</span> <span class="s1">'url'</span><span class="p">));</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'upload_form'</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">'error'</span> <span class="o">=></span> <span class="s1">' '</span> <span class="p">));</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">do_upload</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$config</span><span class="p">[</span><span class="s1">'upload_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'./uploads/'</span><span class="p">;</span> + <span class="nv">$config</span><span class="p">[</span><span class="s1">'allowed_types'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'gif|jpg|png'</span><span class="p">;</span> + <span class="nv">$config</span><span class="p">[</span><span class="s1">'max_size'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span> + <span class="nv">$config</span><span class="p">[</span><span class="s1">'max_width'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1024</span><span class="p">;</span> + <span class="nv">$config</span><span class="p">[</span><span class="s1">'max_height'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">768</span><span class="p">;</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'upload'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">do_upload</span><span class="p">(</span><span class="s1">'userfile'</span><span class="p">))</span> + <span class="p">{</span> + <span class="nv">$error</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'error'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">display_errors</span><span class="p">());</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'upload_form'</span><span class="p">,</span> <span class="nv">$error</span><span class="p">);</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'upload_data'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">data</span><span class="p">());</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'upload_success'</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + <span class="p">}</span> + <span class="p">}</span> +<span class="p">}</span> +<span class="cp">?></span> +</pre></div> +</div> +</div> +<div class="section" id="the-upload-directory"> +<h3><a class="toc-backref" href="#id5">The Upload Directory</a><a class="headerlink" href="#the-upload-directory" title="Permalink to this headline">¶</a></h3> +<p>You’ll need a destination directory for your uploaded images. Create a +directory at the root of your CodeIgniter installation called uploads +and set its file permissions to 777.</p> +</div> +<div class="section" id="try-it"> +<h3><a class="toc-backref" href="#id6">Try it!</a><a class="headerlink" href="#try-it" title="Permalink to this headline">¶</a></h3> +<p>To try your form, visit your site using a URL similar to this one:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">upload</span><span class="o">/</span> +</pre></div> +</div> +<p>You should see an upload form. Try uploading an image file (either a +jpg, gif, or png). If the path in your controller is correct it should +work.</p> +</div> +</div> +<div class="section" id="reference-guide"> +<h2><a class="toc-backref" href="#id7">Reference Guide</a><a class="headerlink" href="#reference-guide" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-upload-class"> +<h3><a class="toc-backref" href="#id8">Initializing the Upload Class</a><a class="headerlink" href="#initializing-the-upload-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Upload class is initialized +in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'upload'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once the Upload class is loaded, the object will be available using: +$this->upload</p> +</div> +<div class="section" id="setting-preferences"> +<h3><a class="toc-backref" href="#id9">Setting Preferences</a><a class="headerlink" href="#setting-preferences" title="Permalink to this headline">¶</a></h3> +<p>Similar to other libraries, you’ll control what is allowed to be upload +based on your preferences. In the controller you built above you set the +following preferences:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'upload_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'./uploads/'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'allowed_types'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'gif|jpg|png'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'max_size'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'100'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'max_width'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'1024'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'max_height'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'768'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'upload'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">);</span> + +<span class="c1">// Alternately you can set preferences by calling the ``initialize()`` method. Useful if you auto-load the class:</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> +</pre></div> +</div> +<p>The above preferences should be fairly self-explanatory. Below is a +table describing all available preferences.</p> +</div> +<div class="section" id="preferences"> +<h3><a class="toc-backref" href="#id10">Preferences</a><a class="headerlink" href="#preferences" title="Permalink to this headline">¶</a></h3> +<p>The following preferences are available. The default value indicates +what will be used if you do not specify that preference.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="20%" /> +<col width="12%" /> +<col width="16%" /> +<col width="51%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default Value</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>upload_path</strong></td> +<td>None</td> +<td>None</td> +<td>The path to the directory where the upload should be placed. The +directory must be writable and the path can be absolute or relative.</td> +</tr> +<tr class="row-odd"><td><strong>allowed_types</strong></td> +<td>None</td> +<td>None</td> +<td>The mime types corresponding to the types of files you allow to be +uploaded. Usually the file extension can be used as the mime type. +Can be either an array or a pipe-separated string.</td> +</tr> +<tr class="row-even"><td><strong>file_name</strong></td> +<td>None</td> +<td>Desired file name</td> +<td>If set CodeIgniter will rename the uploaded file to this name. The +extension provided in the file name must also be an allowed file type. +If no extension is provided in the original file_name will be used.</td> +</tr> +<tr class="row-odd"><td><strong>file_ext_tolower</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>If set to TRUE, the file extension will be forced to lower case</td> +</tr> +<tr class="row-even"><td><strong>overwrite</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>If set to true, if a file with the same name as the one you are +uploading exists, it will be overwritten. If set to false, a number will +be appended to the filename if another with the same name exists.</td> +</tr> +<tr class="row-odd"><td><strong>max_size</strong></td> +<td>0</td> +<td>None</td> +<td>The maximum size (in kilobytes) that the file can be. Set to zero for no +limit. Note: Most PHP installations have their own limit, as specified +in the php.ini file. Usually 2 MB (or 2048 KB) by default.</td> +</tr> +<tr class="row-even"><td><strong>max_width</strong></td> +<td>0</td> +<td>None</td> +<td>The maximum width (in pixels) that the image can be. Set to zero for no +limit.</td> +</tr> +<tr class="row-odd"><td><strong>max_height</strong></td> +<td>0</td> +<td>None</td> +<td>The maximum height (in pixels) that the image can be. Set to zero for no +limit.</td> +</tr> +<tr class="row-even"><td><strong>min_width</strong></td> +<td>0</td> +<td>None</td> +<td>The minimum width (in pixels) that the image can be. Set to zero for no +limit.</td> +</tr> +<tr class="row-odd"><td><strong>min_height</strong></td> +<td>0</td> +<td>None</td> +<td>The minimum height (in pixels) that the image can be. Set to zero for no +limit.</td> +</tr> +<tr class="row-even"><td><strong>max_filename</strong></td> +<td>0</td> +<td>None</td> +<td>The maximum length that a file name can be. Set to zero for no limit.</td> +</tr> +<tr class="row-odd"><td><strong>max_filename_increment</strong></td> +<td>100</td> +<td>None</td> +<td>When overwrite is set to FALSE, use this to set the maximum filename +increment for CodeIgniter to append to the filename.</td> +</tr> +<tr class="row-even"><td><strong>encrypt_name</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>If set to TRUE the file name will be converted to a random encrypted +string. This can be useful if you would like the file saved with a name +that can not be discerned by the person uploading it.</td> +</tr> +<tr class="row-odd"><td><strong>remove_spaces</strong></td> +<td>TRUE</td> +<td>TRUE/FALSE (boolean)</td> +<td>If set to TRUE, any spaces in the file name will be converted to +underscores. This is recommended.</td> +</tr> +<tr class="row-even"><td><strong>detect_mime</strong></td> +<td>TRUE</td> +<td>TRUE/FALSE (boolean)</td> +<td>If set to TRUE, a server side detection of the file type will be +performed to avoid code injection attacks. DO NOT disable this option +unless you have no other option as that would cause a security risk.</td> +</tr> +<tr class="row-odd"><td><strong>mod_mime_fix</strong></td> +<td>TRUE</td> +<td>TRUE/FALSE (boolean)</td> +<td>If set to TRUE, multiple filename extensions will be suffixed with an +underscore in order to avoid triggering <a class="reference external" href="http://httpd.apache.org/docs/2.0/mod/mod_mime.html#multipleext">Apache mod_mime</a>. +DO NOT turn off this option if your upload directory is public, as this +is a security risk.</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="setting-preferences-in-a-config-file"> +<h3><a class="toc-backref" href="#id11">Setting preferences in a config file</a><a class="headerlink" href="#setting-preferences-in-a-config-file" title="Permalink to this headline">¶</a></h3> +<p>If you prefer not to set preferences using the above method, you can +instead put them into a config file. Simply create a new file called the +upload.php, add the $config array in that file. Then save the file in: +<strong>config/upload.php</strong> and it will be used automatically. You will NOT +need to use the <code class="docutils literal"><span class="pre">$this->upload->initialize()</span></code> method if you save your +preferences in a config file.</p> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id12">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Upload"> +<em class="property">class </em><code class="descname">CI_Upload</code><a class="headerlink" href="#CI_Upload" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Upload::initialize"> +<code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>array $config = array()</em><span class="optional">[</span>, <em>$reset = TRUE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Upload::initialize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$config</strong> (<em>array</em>) – Preferences</li> +<li><strong>$reset</strong> (<em>bool</em>) – Whether to reset preferences (that are not provided in $config) to their defaults</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Upload instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Upload</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="CI_Upload::do_upload"> +<code class="descname">do_upload</code><span class="sig-paren">(</span><span class="optional">[</span><em>$field = 'userfile'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Upload::do_upload" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$field</strong> (<em>string</em>) – Name of the form field</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Performs the upload based on the preferences you’ve set.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">By default the upload routine expects the file to come from +a form field called userfile, and the form must be of type +“multipart”.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">form</span> <span class="nx">method</span><span class="o">=</span><span class="s2">"post"</span> <span class="nx">action</span><span class="o">=</span><span class="s2">"some_action"</span> <span class="nx">enctype</span><span class="o">=</span><span class="s2">"multipart/form-data"</span> <span class="o">/></span> +</pre></div> +</div> +<p>If you would like to set your own field name simply pass its value to +the <code class="docutils literal"><span class="pre">do_upload()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$field_name</span> <span class="o">=</span> <span class="s2">"some_field_name"</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">do_upload</span><span class="p">(</span><span class="nv">$field_name</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Upload::display_errors"> +<code class="descname">display_errors</code><span class="sig-paren">(</span><span class="optional">[</span><em>$open = '<p>'</em><span class="optional">[</span>, <em>$close = '</p>'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Upload::display_errors" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$open</strong> (<em>string</em>) – Opening markup</li> +<li><strong>$close</strong> (<em>string</em>) – Closing markup</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Formatted error message(s)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Retrieves any error messages if the <code class="docutils literal"><span class="pre">do_upload()</span></code> method returned +false. The method does not echo automatically, it returns the data so +you can assign it however you need.</p> +<p><strong>Formatting Errors</strong></p> +<blockquote> +<div><p>By default the above method wraps any errors within <p> tags. You can +set your own delimiters like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">display_errors</span><span class="p">(</span><span class="s1">'<p>'</span><span class="p">,</span> <span class="s1">'</p>'</span><span class="p">);</span> +</pre></div> +</div> +</div></blockquote> +</dd></dl> + +<dl class="method"> +<dt id="CI_Upload::data"> +<code class="descname">data</code><span class="sig-paren">(</span><span class="optional">[</span><em>$index = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Upload::data" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>string</em>) – Element to return instead of the full array</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Information about the uploaded file</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This is a helper method that returns an array containing all of the +data related to the file you uploaded. Here is the array prototype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">Array</span> +<span class="p">(</span> + <span class="p">[</span><span class="nx">file_name</span><span class="p">]</span> <span class="o">=></span> <span class="nx">mypic</span><span class="o">.</span><span class="nx">jpg</span> + <span class="p">[</span><span class="nx">file_type</span><span class="p">]</span> <span class="o">=></span> <span class="nx">image</span><span class="o">/</span><span class="nx">jpeg</span> + <span class="p">[</span><span class="nx">file_path</span><span class="p">]</span> <span class="o">=></span> <span class="o">/</span><span class="nx">path</span><span class="o">/</span><span class="nx">to</span><span class="o">/</span><span class="nx">your</span><span class="o">/</span><span class="nx">upload</span><span class="o">/</span> + <span class="p">[</span><span class="nx">full_path</span><span class="p">]</span> <span class="o">=></span> <span class="o">/</span><span class="nx">path</span><span class="o">/</span><span class="nx">to</span><span class="o">/</span><span class="nx">your</span><span class="o">/</span><span class="nx">upload</span><span class="o">/</span><span class="nx">jpg</span><span class="o">.</span><span class="nx">jpg</span> + <span class="p">[</span><span class="nx">raw_name</span><span class="p">]</span> <span class="o">=></span> <span class="nx">mypic</span> + <span class="p">[</span><span class="nx">orig_name</span><span class="p">]</span> <span class="o">=></span> <span class="nx">mypic</span><span class="o">.</span><span class="nx">jpg</span> + <span class="p">[</span><span class="nx">client_name</span><span class="p">]</span> <span class="o">=></span> <span class="nx">mypic</span><span class="o">.</span><span class="nx">jpg</span> + <span class="p">[</span><span class="nx">file_ext</span><span class="p">]</span> <span class="o">=></span> <span class="o">.</span><span class="nx">jpg</span> + <span class="p">[</span><span class="nx">file_size</span><span class="p">]</span> <span class="o">=></span> <span class="mf">22.2</span> + <span class="p">[</span><span class="nx">is_image</span><span class="p">]</span> <span class="o">=></span> <span class="mi">1</span> + <span class="p">[</span><span class="nx">image_width</span><span class="p">]</span> <span class="o">=></span> <span class="mi">800</span> + <span class="p">[</span><span class="nx">image_height</span><span class="p">]</span> <span class="o">=></span> <span class="mi">600</span> + <span class="p">[</span><span class="nx">image_type</span><span class="p">]</span> <span class="o">=></span> <span class="nx">jpeg</span> + <span class="p">[</span><span class="nx">image_size_str</span><span class="p">]</span> <span class="o">=></span> <span class="nx">width</span><span class="o">=</span><span class="s2">"800"</span> <span class="nx">height</span><span class="o">=</span><span class="s2">"200"</span> +<span class="p">)</span> +</pre></div> +</div> +<p>To return one element from the array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">upload</span><span class="o">-></span><span class="na">data</span><span class="p">(</span><span class="s1">'file_name'</span><span class="p">);</span> <span class="c1">// Returns: mypic.jpg</span> +</pre></div> +</div> +<p>Here’s a table explaining the above-displayed array items:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="14%" /> +<col width="86%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Item</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>file_name</td> +<td>Name of the file that was uploaded, including the filename extension</td> +</tr> +<tr class="row-odd"><td>file_type</td> +<td>File MIME type identifier</td> +</tr> +<tr class="row-even"><td>file_path</td> +<td>Absolute server path to the file</td> +</tr> +<tr class="row-odd"><td>full_path</td> +<td>Absolute server path, including the file name</td> +</tr> +<tr class="row-even"><td>raw_name</td> +<td>File name, without the extension</td> +</tr> +<tr class="row-odd"><td>orig_name</td> +<td>Original file name. This is only useful if you use the encrypted name option.</td> +</tr> +<tr class="row-even"><td>client_name</td> +<td>File name supplied by the client user agent, but possibly sanitized</td> +</tr> +<tr class="row-odd"><td>file_ext</td> +<td>Filename extension, period included</td> +</tr> +<tr class="row-even"><td>file_size</td> +<td>File size in kilobytes</td> +</tr> +<tr class="row-odd"><td>is_image</td> +<td>Whether the file is an image or not. 1 = image. 0 = not.</td> +</tr> +<tr class="row-even"><td>image_width</td> +<td>Image width</td> +</tr> +<tr class="row-odd"><td>image_height</td> +<td>Image height</td> +</tr> +<tr class="row-even"><td>image_type</td> +<td>Image type (usually the file name extension without the period)</td> +</tr> +<tr class="row-odd"><td>image_size_str</td> +<td>A string containing the width and height (useful to put into an image tag)</td> +</tr> +</tbody> +</table> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="form_validation.html" class="btn btn-neutral float-right" title="Form Validation">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="encryption.html" class="btn btn-neutral" title="Encryption Library"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html new file mode 100644 index 000000000..f401eb9a6 --- /dev/null +++ b/user_guide/libraries/form_validation.html @@ -0,0 +1,1932 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Form Validation — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="FTP Class" href="ftp.html"/> + <link rel="prev" title="File Uploading Class" href="file_uploading.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Form Validation</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="form-validation"> +<h1><a class="toc-backref" href="#id6">Form Validation</a><a class="headerlink" href="#form-validation" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter provides a comprehensive form validation and data prepping +class that helps minimize the amount of code you’ll write.</p> +<div class="contents topic" id="page-contents"> +<p class="topic-title first">Page Contents</p> +<ul class="simple"> +<li><a class="reference internal" href="#form-validation" id="id6">Form Validation</a><ul> +<li><a class="reference internal" href="#overview" id="id7">Overview</a></li> +<li><a class="reference internal" href="#form-validation-tutorial" id="id8">Form Validation Tutorial</a><ul> +<li><a class="reference internal" href="#the-form" id="id9">The Form</a></li> +<li><a class="reference internal" href="#the-success-page" id="id10">The Success Page</a></li> +<li><a class="reference internal" href="#the-controller" id="id11">The Controller</a></li> +<li><a class="reference internal" href="#try-it" id="id12">Try it!</a></li> +<li><a class="reference internal" href="#explanation" id="id13">Explanation</a></li> +<li><a class="reference internal" href="#setting-validation-rules" id="id14">Setting Validation Rules</a></li> +<li><a class="reference internal" href="#setting-rules-using-an-array" id="id15">Setting Rules Using an Array</a></li> +<li><a class="reference internal" href="#cascading-rules" id="id16">Cascading Rules</a></li> +<li><a class="reference internal" href="#prepping-data" id="id17">Prepping Data</a></li> +<li><a class="reference internal" href="#re-populating-the-form" id="id18">Re-populating the form</a></li> +<li><a class="reference internal" href="#callbacks-your-own-validation-methods" id="id19">Callbacks: Your own Validation Methods</a></li> +<li><a class="reference internal" href="#callable-use-anything-as-a-rule" id="id20">Callable: Use anything as a rule</a></li> +<li><a class="reference internal" href="#setting-error-messages" id="id21">Setting Error Messages</a></li> +<li><a class="reference internal" href="#translating-field-names" id="id22">Translating Field Names</a></li> +<li><a class="reference internal" href="#changing-the-error-delimiters" id="id23">Changing the Error Delimiters</a></li> +<li><a class="reference internal" href="#showing-errors-individually" id="id24">Showing Errors Individually</a></li> +<li><a class="reference internal" href="#validating-an-array-other-than-post" id="id25">Validating an Array (other than $_POST)</a></li> +</ul> +</li> +<li><a class="reference internal" href="#saving-sets-of-validation-rules-to-a-config-file" id="id26">Saving Sets of Validation Rules to a Config File</a><ul> +<li><a class="reference internal" href="#how-to-save-your-rules" id="id27">How to save your rules</a></li> +<li><a class="reference internal" href="#creating-sets-of-rules" id="id28">Creating Sets of Rules</a></li> +<li><a class="reference internal" href="#calling-a-specific-rule-group" id="id29">Calling a Specific Rule Group</a></li> +<li><a class="reference internal" href="#associating-a-controller-method-with-a-rule-group" id="id30">Associating a Controller Method with a Rule Group</a></li> +</ul> +</li> +<li><a class="reference internal" href="#using-arrays-as-field-names" id="id31">Using Arrays as Field Names</a></li> +<li><a class="reference internal" href="#rule-reference" id="id32">Rule Reference</a></li> +<li><a class="reference internal" href="#prepping-reference" id="id33">Prepping Reference</a></li> +<li><a class="reference internal" href="#class-reference" id="id34">Class Reference</a></li> +<li><a class="reference internal" href="#helper-reference" id="id35">Helper Reference</a></li> +</ul> +</li> +</ul> +</div> +<div class="section" id="overview"> +<h2><a class="toc-backref" href="#id7">Overview</a><a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2> +<p>Before explaining CodeIgniter’s approach to data validation, let’s +describe the ideal scenario:</p> +<ol class="arabic simple"> +<li>A form is displayed.</li> +<li>You fill it in and submit it.</li> +<li>If you submitted something invalid, or perhaps missed a required +item, the form is redisplayed containing your data along with an +error message describing the problem.</li> +<li>This process continues until you have submitted a valid form.</li> +</ol> +<p>On the receiving end, the script must:</p> +<ol class="arabic simple"> +<li>Check for required data.</li> +<li>Verify that the data is of the correct type, and meets the correct +criteria. For example, if a username is submitted it must be +validated to contain only permitted characters. It must be of a +minimum length, and not exceed a maximum length. The username can’t +be someone else’s existing username, or perhaps even a reserved word. +Etc.</li> +<li>Sanitize the data for security.</li> +<li>Pre-format the data if needed (Does the data need to be trimmed? HTML +encoded? Etc.)</li> +<li>Prep the data for insertion in the database.</li> +</ol> +<p>Although there is nothing terribly complex about the above process, it +usually requires a significant amount of code, and to display error +messages, various control structures are usually placed within the form +HTML. Form validation, while simple to create, is generally very messy +and tedious to implement.</p> +</div> +<div class="section" id="form-validation-tutorial"> +<h2><a class="toc-backref" href="#id8">Form Validation Tutorial</a><a class="headerlink" href="#form-validation-tutorial" title="Permalink to this headline">¶</a></h2> +<p>What follows is a “hands on” tutorial for implementing CodeIgniter’s Form +Validation.</p> +<p>In order to implement form validation you’ll need three things:</p> +<ol class="arabic simple"> +<li>A <a class="reference internal" href="../general/views.html"><span class="doc">View</span></a> file containing a form.</li> +<li>A View file containing a “success” message to be displayed upon +successful submission.</li> +<li>A <a class="reference internal" href="../general/controllers.html"><span class="doc">controller</span></a> method to receive and +process the submitted data.</li> +</ol> +<p>Let’s create those three things, using a member sign-up form as the +example.</p> +<div class="section" id="the-form"> +<h3><a class="toc-backref" href="#id9">The Form</a><a class="headerlink" href="#the-form" title="Permalink to this headline">¶</a></h3> +<p>Using a text editor, create a form called myform.php. In it, place this +code and save it to your application/views/ folder:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> +<span class="o"><</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="nx">My</span> <span class="nx">Form</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> +<span class="o"></</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">body</span><span class="o">></span> + +<span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">validation_errors</span><span class="p">();</span> <span class="cp">?></span> + +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">'form'</span><span class="p">);</span> <span class="cp">?></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Username<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"username"</span> <span class="na">value</span><span class="o">=</span><span class="s">""</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Password<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"password"</span> <span class="na">value</span><span class="o">=</span><span class="s">""</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Password Confirm<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"passconf"</span> <span class="na">value</span><span class="o">=</span><span class="s">""</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Email Address<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"email"</span> <span class="na">value</span><span class="o">=</span><span class="s">""</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">div</span><span class="p">><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"submit"</span> <span class="na">value</span><span class="o">=</span><span class="s">"Submit"</span> <span class="p">/></</span><span class="nt">div</span><span class="p">></span> + +<span class="p"></</span><span class="nt">form</span><span class="p">></span> + +<span class="p"></</span><span class="nt">body</span><span class="p">></span> +<span class="p"></</span><span class="nt">html</span><span class="p">></span> +</pre></div> +</div> +</div> +<div class="section" id="the-success-page"> +<h3><a class="toc-backref" href="#id10">The Success Page</a><a class="headerlink" href="#the-success-page" title="Permalink to this headline">¶</a></h3> +<p>Using a text editor, create a form called formsuccess.php. In it, place +this code and save it to your application/views/ folder:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> +<span class="o"><</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="nx">My</span> <span class="nx">Form</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> +<span class="o"></</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">body</span><span class="o">></span> + +<span class="o"><</span><span class="nx">h3</span><span class="o">></span><span class="nx">Your</span> <span class="nx">form</span> <span class="nx">was</span> <span class="nx">successfully</span> <span class="nx">submitted</span><span class="o">!</</span><span class="nx">h3</span><span class="o">></span> + +<span class="o"><</span><span class="nx">p</span><span class="o">><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">anchor</span><span class="p">(</span><span class="s1">'form'</span><span class="p">,</span> <span class="s1">'Try it again!'</span><span class="p">);</span> <span class="cp">?></span><span class="p"></</span><span class="nt">p</span><span class="p">></span> + +<span class="p"></</span><span class="nt">body</span><span class="p">></span> +<span class="p"></</span><span class="nt">html</span><span class="p">></span> +</pre></div> +</div> +</div> +<div class="section" id="the-controller"> +<h3><a class="toc-backref" href="#id11">The Controller</a><a class="headerlink" href="#the-controller" title="Permalink to this headline">¶</a></h3> +<p>Using a text editor, create a controller called Form.php. In it, place +this code and save it to your application/controllers/ folder:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Form</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">helper</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'form'</span><span class="p">,</span> <span class="s1">'url'</span><span class="p">));</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">run</span><span class="p">()</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'myform'</span><span class="p">);</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'formsuccess'</span><span class="p">);</span> + <span class="p">}</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +</div> +<div class="section" id="try-it"> +<h3><a class="toc-backref" href="#id12">Try it!</a><a class="headerlink" href="#try-it" title="Permalink to this headline">¶</a></h3> +<p>To try your form, visit your site using a URL similar to this one:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">form</span><span class="o">/</span> +</pre></div> +</div> +<p>If you submit the form you should simply see the form reload. That’s +because you haven’t set up any validation rules yet.</p> +<p><strong>Since you haven’t told the Form Validation class to validate anything +yet, it returns FALSE (boolean false) by default. ``The run()`` method +only returns TRUE if it has successfully applied your rules without any +of them failing.</strong></p> +</div> +<div class="section" id="explanation"> +<h3><a class="toc-backref" href="#id13">Explanation</a><a class="headerlink" href="#explanation" title="Permalink to this headline">¶</a></h3> +<p>You’ll notice several things about the above pages:</p> +<p>The form (myform.php) is a standard web form with a couple exceptions:</p> +<ol class="arabic"> +<li><p class="first">It uses a form helper to create the form opening. Technically, this +isn’t necessary. You could create the form using standard HTML. +However, the benefit of using the helper is that it generates the +action URL for you, based on the URL in your config file. This makes +your application more portable in the event your URLs change.</p> +</li> +<li><p class="first">At the top of the form you’ll notice the following function call:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">validation_errors</span><span class="p">();</span> <span class="cp">?></span> +</pre></div> +</div> +<p>This function will return any error messages sent back by the +validator. If there are no messages it returns an empty string.</p> +</li> +</ol> +<p>The controller (Form.php) has one method: <code class="docutils literal"><span class="pre">index()</span></code>. This method +initializes the validation class and loads the form helper and URL +helper used by your view files. It also runs the validation routine. +Based on whether the validation was successful it either presents the +form or the success page.</p> +</div> +<div class="section" id="setting-validation-rules"> +<span id="id1"></span><h3><a class="toc-backref" href="#id14">Setting Validation Rules</a><a class="headerlink" href="#setting-validation-rules" title="Permalink to this headline">¶</a></h3> +<p>CodeIgniter lets you set as many validation rules as you need for a +given field, cascading them in order, and it even lets you prep and +pre-process the field data at the same time. To set validation rules you +will use the <code class="docutils literal"><span class="pre">set_rules()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">();</span> +</pre></div> +</div> +<p>The above method takes <strong>three</strong> parameters as input:</p> +<ol class="arabic simple"> +<li>The field name - the exact name you’ve given the form field.</li> +<li>A “human” name for this field, which will be inserted into the error +message. For example, if your field is named “user” you might give it +a human name of “Username”.</li> +<li>The validation rules for this form field.</li> +<li>(optional) Set custom error messages on any rules given for current field. If not provided will use the default one.</li> +</ol> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If you would like the field name to be stored in a language +file, please see <a class="reference internal" href="#translating-field-names"><span class="std std-ref">Translating Field Names</span></a>.</p> +</div> +<p>Here is an example. In your controller (Form.php), add this code just +below the validation initialization method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'password'</span><span class="p">,</span> <span class="s1">'Password'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">,</span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="s1">'Email'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +</pre></div> +</div> +<p>Your controller should now look like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Form</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">helper</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'form'</span><span class="p">,</span> <span class="s1">'url'</span><span class="p">));</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">);</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'password'</span><span class="p">,</span> <span class="s1">'Password'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'required'</span> <span class="o">=></span> <span class="s1">'You must provide a %s.'</span><span class="p">)</span> + <span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">,</span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="s1">'Email'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">run</span><span class="p">()</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'myform'</span><span class="p">);</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'formsuccess'</span><span class="p">);</span> + <span class="p">}</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +<p>Now submit the form with the fields blank and you should see the error +messages. If you submit the form with all the fields populated you’ll +see your success page.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The form fields are not yet being re-populated with the data +when there is an error. We’ll get to that shortly.</p> +</div> +</div> +<div class="section" id="setting-rules-using-an-array"> +<h3><a class="toc-backref" href="#id15">Setting Rules Using an Array</a><a class="headerlink" href="#setting-rules-using-an-array" title="Permalink to this headline">¶</a></h3> +<p>Before moving on it should be noted that the rule setting method can +be passed an array if you prefer to set all your rules in one action. If +you use this approach, you must name your array keys as indicated:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'username'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'password'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span><span class="p">,</span> + <span class="s1">'errors'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'required'</span> <span class="o">=></span> <span class="s1">'You must provide a %s.'</span><span class="p">,</span> + <span class="p">),</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'passconf'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'email'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Email'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="cascading-rules"> +<h3><a class="toc-backref" href="#id16">Cascading Rules</a><a class="headerlink" href="#cascading-rules" title="Permalink to this headline">¶</a></h3> +<p>CodeIgniter lets you pipe multiple rules together. Let’s try it. Change +your rules in the third parameter of rule setting method, like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span> + <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="s1">'required|min_length[5]|max_length[12]|is_unique[users.username]'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'required'</span> <span class="o">=></span> <span class="s1">'You have not provided %s.'</span><span class="p">,</span> + <span class="s1">'is_unique'</span> <span class="o">=></span> <span class="s1">'This %s already exists.'</span> + <span class="p">)</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'password'</span><span class="p">,</span> <span class="s1">'Password'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">,</span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> <span class="s1">'required|matches[password]'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="s1">'Email'</span><span class="p">,</span> <span class="s1">'required|valid_email|is_unique[users.email]'</span><span class="p">);</span> +</pre></div> +</div> +<p>The above code sets the following rules:</p> +<ol class="arabic simple"> +<li>The username field be no shorter than 5 characters and no longer than +12.</li> +<li>The password field must match the password confirmation field.</li> +<li>The email field must contain a valid email address.</li> +</ol> +<p>Give it a try! Submit your form without the proper data and you’ll see +new error messages that correspond to your new rules. There are numerous +rules available which you can read about in the validation reference.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p>You can also pass an array of rules to <code class="docutils literal"><span class="pre">set_rules()</span></code>, +instead of a string. Example:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">'required'</span><span class="p">,</span> <span class="s1">'min_length[5]'</span><span class="p">));</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="prepping-data"> +<h3><a class="toc-backref" href="#id17">Prepping Data</a><a class="headerlink" href="#prepping-data" title="Permalink to this headline">¶</a></h3> +<p>In addition to the validation method like the ones we used above, you +can also prep your data in various ways. For example, you can set up +rules like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> <span class="s1">'trim|required|min_length[5]|max_length[12]'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'password'</span><span class="p">,</span> <span class="s1">'Password'</span><span class="p">,</span> <span class="s1">'trim|required|min_length[8]'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">,</span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> <span class="s1">'trim|required|matches[password]'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="s1">'Email'</span><span class="p">,</span> <span class="s1">'trim|required|valid_email'</span><span class="p">);</span> +</pre></div> +</div> +<p>In the above example, we are “trimming” the fields, checking for length +where necessary and making sure that both password fields match.</p> +<p><strong>Any native PHP function that accepts one parameter can be used as a +rule, like ``htmlspecialchars()``, ``trim()``, etc.</strong></p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You will generally want to use the prepping functions +<strong>after</strong> the validation rules so if there is an error, the +original data will be shown in the form.</p> +</div> +</div> +<div class="section" id="re-populating-the-form"> +<h3><a class="toc-backref" href="#id18">Re-populating the form</a><a class="headerlink" href="#re-populating-the-form" title="Permalink to this headline">¶</a></h3> +<p>Thus far we have only been dealing with errors. It’s time to repopulate +the form field with the submitted data. CodeIgniter offers several +helper functions that permit you to do this. The one you will use most +commonly is:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">set_value</span><span class="p">(</span><span class="s1">'field name'</span><span class="p">)</span> +</pre></div> +</div> +<p>Open your myform.php view file and update the <strong>value</strong> in each field +using the <a class="reference internal" href="../helpers/form_helper.html#set_value" title="set_value"><code class="xref php php-func docutils literal"><span class="pre">set_value()</span></code></a> function:</p> +<p><strong>Don’t forget to include each field name in the :php:func:`set_value()` +function calls!</strong></p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> +<span class="o"><</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="nx">My</span> <span class="nx">Form</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> +<span class="o"></</span><span class="nx">head</span><span class="o">></span> +<span class="o"><</span><span class="nx">body</span><span class="o">></span> + +<span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">validation_errors</span><span class="p">();</span> <span class="cp">?></span> + +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">'form'</span><span class="p">);</span> <span class="cp">?></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Username<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"username"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'username'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Password<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"password"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'password'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Password Confirm<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"passconf"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Email Address<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"email"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'email'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">div</span><span class="p">><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"submit"</span> <span class="na">value</span><span class="o">=</span><span class="s">"Submit"</span> <span class="p">/></</span><span class="nt">div</span><span class="p">></span> + +<span class="p"></</span><span class="nt">form</span><span class="p">></span> + +<span class="p"></</span><span class="nt">body</span><span class="p">></span> +<span class="p"></</span><span class="nt">html</span><span class="p">></span> +</pre></div> +</div> +<p>Now reload your page and submit the form so that it triggers an error. +Your form fields should now be re-populated</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The <a class="reference internal" href="#class-reference"><span class="std std-ref">Class Reference</span></a> section below +contains methods that permit you to re-populate <select> menus, +radio buttons, and checkboxes.</p> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p>If you use an array as the name of a form field, you +must supply it as an array to the function. Example:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"text"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"colors[]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"<?php echo set_value('colors[]'); ?>"</span> <span class="nx">size</span><span class="o">=</span><span class="s2">"50"</span> <span class="o">/></span> +</pre></div> +</div> +</div> +<p>For more info please see the <a class="reference internal" href="#using-arrays-as-field-names"><span class="std std-ref">Using Arrays as Field Names</span></a> section below.</p> +</div> +<div class="section" id="callbacks-your-own-validation-methods"> +<h3><a class="toc-backref" href="#id19">Callbacks: Your own Validation Methods</a><a class="headerlink" href="#callbacks-your-own-validation-methods" title="Permalink to this headline">¶</a></h3> +<p>The validation system supports callbacks to your own validation +methods. This permits you to extend the validation class to meet your +needs. For example, if you need to run a database query to see if the +user is choosing a unique username, you can create a callback method +that does that. Let’s create an example of this.</p> +<p>In your controller, change the “username” rule to this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> <span class="s1">'callback_username_check'</span><span class="p">);</span> +</pre></div> +</div> +<p>Then add a new method called <code class="docutils literal"><span class="pre">username_check()</span></code> to your controller. +Here’s how your controller should now look:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Form</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">helper</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'form'</span><span class="p">,</span> <span class="s1">'url'</span><span class="p">));</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">);</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> <span class="s1">'callback_username_check'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'password'</span><span class="p">,</span> <span class="s1">'Password'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">,</span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="s1">'Email'</span><span class="p">,</span> <span class="s1">'required|is_unique[users.email]'</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">run</span><span class="p">()</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'myform'</span><span class="p">);</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'formsuccess'</span><span class="p">);</span> + <span class="p">}</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">username_check</span><span class="p">(</span><span class="nv">$str</span><span class="p">)</span> + <span class="p">{</span> + <span class="k">if</span> <span class="p">(</span><span class="nv">$str</span> <span class="o">==</span> <span class="s1">'test'</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_message</span><span class="p">(</span><span class="s1">'username_check'</span><span class="p">,</span> <span class="s1">'The {field} field can not be the word "test"'</span><span class="p">);</span> + <span class="k">return</span> <span class="k">FALSE</span><span class="p">;</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="k">return</span> <span class="k">TRUE</span><span class="p">;</span> + <span class="p">}</span> + <span class="p">}</span> + +<span class="p">}</span> +</pre></div> +</div> +<p>Reload your form and submit it with the word “test” as the username. You +can see that the form field data was passed to your callback method +for you to process.</p> +<p>To invoke a callback just put the method name in a rule, with +“callback_” as the rule <strong>prefix</strong>. If you need to receive an extra +parameter in your callback method, just add it normally after the +method name between square brackets, as in: <code class="docutils literal"><span class="pre">callback_foo[bar]</span></code>, +then it will be passed as the second argument of your callback method.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You can also process the form data that is passed to your +callback and return it. If your callback returns anything other than a +boolean TRUE/FALSE it is assumed that the data is your newly processed +form data.</p> +</div> +</div> +<div class="section" id="callable-use-anything-as-a-rule"> +<h3><a class="toc-backref" href="#id20">Callable: Use anything as a rule</a><a class="headerlink" href="#callable-use-anything-as-a-rule" title="Permalink to this headline">¶</a></h3> +<p>If callback rules aren’t good enough for you (for example, because they are +limited to your controller), don’t get disappointed, there’s one more way +to create custom rules: anything that <code class="docutils literal"><span class="pre">is_callable()</span></code> would return TRUE for.</p> +<p>Consider the following example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span> + <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'required'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">users_model</span><span class="p">,</span> <span class="s1">'valid_username'</span><span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>The above code would use the <code class="docutils literal"><span class="pre">valid_username()</span></code> method from your +<code class="docutils literal"><span class="pre">Users_model</span></code> object.</p> +<p>This is just an example of course, and callbacks aren’t limited to models. +You can use any object/method that accepts the field value as its’ first +parameter. You can also use an anonymous function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span> + <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'required'</span><span class="p">,</span> + <span class="k">function</span><span class="p">(</span><span class="nv">$value</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Check $value</span> + <span class="p">}</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Of course, since a Callable rule by itself is not a string, it isn’t +a rule name either. That is a problem when you want to set error messages +for them. In order to get around that problem, you can put such rules as +the second element of an array, with the first one being the rule name:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span> + <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'required'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'username_callable'</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">users_model</span><span class="p">,</span> <span class="s1">'valid_username'</span><span class="p">))</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Anonymous function version:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span> + <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'required'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'username_callable'</span><span class="p">,</span> + <span class="k">function</span><span class="p">(</span><span class="nv">$str</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Check validity of $str and return TRUE or FALSE</span> + <span class="p">}</span> + <span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="setting-error-messages"> +<span id="id2"></span><h3><a class="toc-backref" href="#id21">Setting Error Messages</a><a class="headerlink" href="#setting-error-messages" title="Permalink to this headline">¶</a></h3> +<p>All of the native error messages are located in the following language +file: <strong>system/language/english/form_validation_lang.php</strong></p> +<p>To set your own global custom message for a rule, you can either +extend/override the language file by creating your own in +<strong>application/language/english/form_validation_lang.php</strong> (read more +about this in the <a class="reference internal" href="language.html"><span class="doc">Language Class</span></a> documentation), +or use the following method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_message</span><span class="p">(</span><span class="s1">'rule'</span><span class="p">,</span> <span class="s1">'Error Message'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you need to set a custom error message for a particular field on +some particular rule, use the set_rules() method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'field_name'</span><span class="p">,</span> <span class="s1">'Field Label'</span><span class="p">,</span> <span class="s1">'rule1|rule2|rule3'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'rule2'</span> <span class="o">=></span> <span class="s1">'Error Message on rule2 for this field_name'</span><span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Where rule corresponds to the name of a particular rule, and Error +Message is the text you would like displayed.</p> +<p>If you’d like to include a field’s “human” name, or the optional +parameter some rules allow for (such as max_length), you can add the +<strong>{field}</strong> and <strong>{param}</strong> tags to your message, respectively:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_message</span><span class="p">(</span><span class="s1">'min_length'</span><span class="p">,</span> <span class="s1">'{field} must have at least {param} characters.'</span><span class="p">);</span> +</pre></div> +</div> +<p>On a field with the human name Username and a rule of min_length[5], an +error would display: “Username must have at least 5 characters.”</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The old <cite>sprintf()</cite> method of using <strong>%s</strong> in your error messages +will still work, however it will override the tags above. You should +use one or the other.</p> +</div> +<p>In the callback rule example above, the error message was set by passing +the name of the method (without the “callback_” prefix):</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_message</span><span class="p">(</span><span class="s1">'username_check'</span><span class="p">)</span> +</pre></div> +</div> +</div> +<div class="section" id="translating-field-names"> +<span id="id3"></span><h3><a class="toc-backref" href="#id22">Translating Field Names</a><a class="headerlink" href="#translating-field-names" title="Permalink to this headline">¶</a></h3> +<p>If you would like to store the “human” name you passed to the +<code class="docutils literal"><span class="pre">set_rules()</span></code> method in a language file, and therefore make the name +able to be translated, here’s how:</p> +<p>First, prefix your “human” name with <strong>lang:</strong>, as in this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'first_name'</span><span class="p">,</span> <span class="s1">'lang:first_name'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +</pre></div> +</div> +<p>Then, store the name in one of your language file arrays (without the +prefix):</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$lang</span><span class="p">[</span><span class="s1">'first_name'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'First Name'</span><span class="p">;</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p>If you store your array item in a language file that is not +loaded automatically by CI, you’ll need to remember to load it in your +controller using:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'file_name'</span><span class="p">);</span> +</pre></div> +</div> +</div> +<p>See the <a class="reference internal" href="language.html"><span class="doc">Language Class</span></a> page for more info regarding +language files.</p> +</div> +<div class="section" id="changing-the-error-delimiters"> +<span id="changing-delimiters"></span><h3><a class="toc-backref" href="#id23">Changing the Error Delimiters</a><a class="headerlink" href="#changing-the-error-delimiters" title="Permalink to this headline">¶</a></h3> +<p>By default, the Form Validation class adds a paragraph tag (<p>) around +each error message shown. You can either change these delimiters +globally, individually, or change the defaults in a config file.</p> +<ol class="arabic"> +<li><p class="first"><strong>Changing delimiters Globally</strong> +To globally change the error delimiters, in your controller method, +just after loading the Form Validation class, add this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_error_delimiters</span><span class="p">(</span><span class="s1">'<div class="error">'</span><span class="p">,</span> <span class="s1">'</div>'</span><span class="p">);</span> +</pre></div> +</div> +<p>In this example, we’ve switched to using div tags.</p> +</li> +<li><p class="first"><strong>Changing delimiters Individually</strong> +Each of the two error generating functions shown in this tutorial can +be supplied their own delimiters as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'field name'</span><span class="p">,</span> <span class="s1">'<div class="error">'</span><span class="p">,</span> <span class="s1">'</div>'</span><span class="p">);</span> <span class="cp">?></span> +</pre></div> +</div> +<p>Or:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">validation_errors</span><span class="p">(</span><span class="s1">'<div class="error">'</span><span class="p">,</span> <span class="s1">'</div>'</span><span class="p">);</span> <span class="cp">?></span> +</pre></div> +</div> +</li> +<li><p class="first"><strong>Set delimiters in a config file</strong> +You can add your error delimiters in application/config/form_validation.php as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'error_prefix'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'<div class="error_prefix">'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'error_suffix'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'</div>'</span><span class="p">;</span> +</pre></div> +</div> +</li> +</ol> +</div> +<div class="section" id="showing-errors-individually"> +<h3><a class="toc-backref" href="#id24">Showing Errors Individually</a><a class="headerlink" href="#showing-errors-individually" title="Permalink to this headline">¶</a></h3> +<p>If you prefer to show an error message next to each form field, rather +than as a list, you can use the <a class="reference internal" href="../helpers/form_helper.html#form_error" title="form_error"><code class="xref php php-func docutils literal"><span class="pre">form_error()</span></code></a> function.</p> +<p>Try it! Change your form so that it looks like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">h5</span><span class="o">></span><span class="nx">Username</span><span class="o"></</span><span class="nx">h5</span><span class="o">></span> +<span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'username'</span><span class="p">);</span> <span class="cp">?></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"username"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'username'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Password<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'password'</span><span class="p">);</span> <span class="cp">?></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"password"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'password'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Password Confirm<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">);</span> <span class="cp">?></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"passconf"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'passconf'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> + +<span class="p"><</span><span class="nt">h5</span><span class="p">></span>Email Address<span class="p"></</span><span class="nt">h5</span><span class="p">></span> +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'email'</span><span class="p">);</span> <span class="cp">?></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"email"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s1">'email'</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> +</pre></div> +</div> +<p>If there are no errors, nothing will be shown. If there is an error, the +message will appear.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p>If you use an array as the name of a form field, you +must supply it as an array to the function. Example:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'options[size]'</span><span class="p">);</span> <span class="cp">?></span> +<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"text"</span> <span class="na">name</span><span class="o">=</span><span class="s">"options[size]"</span> <span class="na">value</span><span class="o">=</span><span class="s">"</span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nx">set_value</span><span class="p">(</span><span class="s2">"options[size]"</span><span class="p">);</span> <span class="cp">?></span><span class="s">"</span> <span class="na">size</span><span class="o">=</span><span class="s">"50"</span> <span class="p">/></span> +</pre></div> +</div> +</div> +<p>For more info please see the <a class="reference internal" href="#using-arrays-as-field-names"><span class="std std-ref">Using Arrays as Field Names</span></a> section below.</p> +</div> +<div class="section" id="validating-an-array-other-than-post"> +<h3><a class="toc-backref" href="#id25">Validating an Array (other than $_POST)</a><a class="headerlink" href="#validating-an-array-other-than-post" title="Permalink to this headline">¶</a></h3> +<p>Sometimes you may want to validate an array that does not originate from <code class="docutils literal"><span class="pre">$_POST</span></code> data.</p> +<p>In this case, you can specify the array to be validated:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'username'</span> <span class="o">=></span> <span class="s1">'johndoe'</span><span class="p">,</span> + <span class="s1">'password'</span> <span class="o">=></span> <span class="s1">'mypassword'</span><span class="p">,</span> + <span class="s1">'passconf'</span> <span class="o">=></span> <span class="s1">'mypassword'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_data</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>Creating validation rules, running the validation, and retrieving error +messages works the same whether you are validating <code class="docutils literal"><span class="pre">$_POST</span></code> data or +another array of your choice.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">You have to call the <code class="docutils literal"><span class="pre">set_data()</span></code> method <em>before</em> defining +any validation rules.</p> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">If you want to validate more than one array during a single +execution, then you should call the <code class="docutils literal"><span class="pre">reset_validation()</span></code> method +before setting up rules and validating the new array.</p> +</div> +<p>For more info please see the <a class="reference internal" href="#class-reference"><span class="std std-ref">Class Reference</span></a> section below.</p> +</div> +</div> +<div class="section" id="saving-sets-of-validation-rules-to-a-config-file"> +<span id="saving-groups"></span><h2><a class="toc-backref" href="#id26">Saving Sets of Validation Rules to a Config File</a><a class="headerlink" href="#saving-sets-of-validation-rules-to-a-config-file" title="Permalink to this headline">¶</a></h2> +<p>A nice feature of the Form Validation class is that it permits you to +store all your validation rules for your entire application in a config +file. You can organize these rules into “groups”. These groups can +either be loaded automatically when a matching controller/method is +called, or you can manually call each set as needed.</p> +<div class="section" id="how-to-save-your-rules"> +<h3><a class="toc-backref" href="#id27">How to save your rules</a><a class="headerlink" href="#how-to-save-your-rules" title="Permalink to this headline">¶</a></h3> +<p>To store your validation rules, simply create a file named +form_validation.php in your application/config/ folder. In that file +you will place an array named $config with your rules. As shown earlier, +the validation array will have this prototype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'username'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'password'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'passconf'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'email'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Email'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Your validation rule file will be loaded automatically and used when you +call the <code class="docutils literal"><span class="pre">run()</span></code> method.</p> +<p>Please note that you MUST name your <code class="docutils literal"><span class="pre">$config</span></code> array.</p> +</div> +<div class="section" id="creating-sets-of-rules"> +<h3><a class="toc-backref" href="#id28">Creating Sets of Rules</a><a class="headerlink" href="#creating-sets-of-rules" title="Permalink to this headline">¶</a></h3> +<p>In order to organize your rules into “sets” requires that you place them +into “sub arrays”. Consider the following example, showing two sets of +rules. We’ve arbitrarily called these two rules “signup” and “email”. +You can name your rules anything you want:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'signup'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'username'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'password'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'passconf'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password Confirmation'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'email'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Email'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">)</span> + <span class="p">),</span> + <span class="s1">'email'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'emailaddress'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'EmailAddress'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required|valid_email'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'name'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Name'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required|alpha'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'title'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Title'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'message'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'MessageBody'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="calling-a-specific-rule-group"> +<h3><a class="toc-backref" href="#id29">Calling a Specific Rule Group</a><a class="headerlink" href="#calling-a-specific-rule-group" title="Permalink to this headline">¶</a></h3> +<p>In order to call a specific group, you will pass its name to the <code class="docutils literal"><span class="pre">run()</span></code> +method. For example, to call the signup rule you will do this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">run</span><span class="p">(</span><span class="s1">'signup'</span><span class="p">)</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'myform'</span><span class="p">);</span> +<span class="p">}</span> +<span class="k">else</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'formsuccess'</span><span class="p">);</span> +<span class="p">}</span> +</pre></div> +</div> +</div> +<div class="section" id="associating-a-controller-method-with-a-rule-group"> +<h3><a class="toc-backref" href="#id30">Associating a Controller Method with a Rule Group</a><a class="headerlink" href="#associating-a-controller-method-with-a-rule-group" title="Permalink to this headline">¶</a></h3> +<p>An alternate (and more automatic) method of calling a rule group is to +name it according to the controller class/method you intend to use it +with. For example, let’s say you have a controller named Member and a +method named signup. Here’s what your class might look like:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Member</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">signup</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">run</span><span class="p">()</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'myform'</span><span class="p">);</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'formsuccess'</span><span class="p">);</span> + <span class="p">}</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +<p>In your validation config file, you will name your rule group +member/signup:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'member/signup'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'username'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Username'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'password'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Password'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'passconf'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'PasswordConfirmation'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'field'</span> <span class="o">=></span> <span class="s1">'email'</span><span class="p">,</span> + <span class="s1">'label'</span> <span class="o">=></span> <span class="s1">'Email'</span><span class="p">,</span> + <span class="s1">'rules'</span> <span class="o">=></span> <span class="s1">'required'</span> + <span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>When a rule group is named identically to a controller class/method it +will be used automatically when the <code class="docutils literal"><span class="pre">run()</span></code> method is invoked from that +class/method.</p> +</div> +</div> +<div class="section" id="using-arrays-as-field-names"> +<span id="id4"></span><h2><a class="toc-backref" href="#id31">Using Arrays as Field Names</a><a class="headerlink" href="#using-arrays-as-field-names" title="Permalink to this headline">¶</a></h2> +<p>The Form Validation class supports the use of arrays as field names. +Consider this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"text"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">""</span> <span class="nx">size</span><span class="o">=</span><span class="s2">"50"</span> <span class="o">/></span> +</pre></div> +</div> +<p>If you do use an array as a field name, you must use the EXACT array +name in the <a class="reference internal" href="#helper-functions"><span class="std std-ref">Helper Functions</span></a> that require the +field name, and as your Validation Rule field name.</p> +<p>For example, to set a rule for the above field you would use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">set_rules</span><span class="p">(</span><span class="s1">'options[]'</span><span class="p">,</span> <span class="s1">'Options'</span><span class="p">,</span> <span class="s1">'required'</span><span class="p">);</span> +</pre></div> +</div> +<p>Or, to show an error for the above field you would use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'options[]'</span><span class="p">);</span> <span class="cp">?></span> +</pre></div> +</div> +<p>Or to re-populate the field you would use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"text"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"<?php echo set_value('options[]'); ?>"</span> <span class="nx">size</span><span class="o">=</span><span class="s2">"50"</span> <span class="o">/></span> +</pre></div> +</div> +<p>You can use multidimensional arrays as field names as well. For example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"text"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[size]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">""</span> <span class="nx">size</span><span class="o">=</span><span class="s2">"50"</span> <span class="o">/></span> +</pre></div> +</div> +<p>Or even:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"text"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"sports[nba][basketball]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">""</span> <span class="nx">size</span><span class="o">=</span><span class="s2">"50"</span> <span class="o">/></span> +</pre></div> +</div> +<p>As with our first example, you must use the exact array name in the +helper functions:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'sports[nba][basketball]'</span><span class="p">);</span> <span class="cp">?></span> +</pre></div> +</div> +<p>If you are using checkboxes (or other fields) that have multiple +options, don’t forget to leave an empty bracket after each option, so +that all selections will be added to the POST array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"red"</span> <span class="o">/></span> +<span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"blue"</span> <span class="o">/></span> +<span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"green"</span> <span class="o">/></span> +</pre></div> +</div> +<p>Or if you use a multidimensional array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[color][]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"red"</span> <span class="o">/></span> +<span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[color][]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"blue"</span> <span class="o">/></span> +<span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"options[color][]"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"green"</span> <span class="o">/></span> +</pre></div> +</div> +<p>When you use a helper function you’ll include the bracket as well:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">'options[color][]'</span><span class="p">);</span> <span class="cp">?></span> +</pre></div> +</div> +</div> +<div class="section" id="rule-reference"> +<h2><a class="toc-backref" href="#id32">Rule Reference</a><a class="headerlink" href="#rule-reference" title="Permalink to this headline">¶</a></h2> +<p>The following is a list of all the native rules that are available to +use:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="16%" /> +<col width="7%" /> +<col width="61%" /> +<col width="16%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Rule</th> +<th class="head">Parameter</th> +<th class="head">Description</th> +<th class="head">Example</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>required</strong></td> +<td>No</td> +<td>Returns FALSE if the form element is empty.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>matches</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element does not match the one in the parameter.</td> +<td>matches[form_item]</td> +</tr> +<tr class="row-even"><td><strong>regex_match</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element does not match the regular expression.</td> +<td>regex_match[/regex/]</td> +</tr> +<tr class="row-odd"><td><strong>differs</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element does not differ from the one in the parameter.</td> +<td>differs[form_item]</td> +</tr> +<tr class="row-even"><td><strong>is_unique</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is not unique to the table and field name in the +parameter. Note: This rule requires <a class="reference internal" href="../database/query_builder.html"><span class="doc">Query Builder</span></a> to be +enabled in order to work.</td> +<td>is_unique[table.field]</td> +</tr> +<tr class="row-odd"><td><strong>min_length</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is shorter than the parameter value.</td> +<td>min_length[3]</td> +</tr> +<tr class="row-even"><td><strong>max_length</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is longer than the parameter value.</td> +<td>max_length[12]</td> +</tr> +<tr class="row-odd"><td><strong>exact_length</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is not exactly the parameter value.</td> +<td>exact_length[8]</td> +</tr> +<tr class="row-even"><td><strong>greater_than</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is less than or equal to the parameter value or not +numeric.</td> +<td>greater_than[8]</td> +</tr> +<tr class="row-odd"><td><strong>greater_than_equal_to</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is less than the parameter value, +or not numeric.</td> +<td>greater_than_equal_to[8]</td> +</tr> +<tr class="row-even"><td><strong>less_than</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is greater than or equal to the parameter value or +not numeric.</td> +<td>less_than[8]</td> +</tr> +<tr class="row-odd"><td><strong>less_than_equal_to</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is greater than the parameter value, +or not numeric.</td> +<td>less_than_equal_to[8]</td> +</tr> +<tr class="row-even"><td><strong>in_list</strong></td> +<td>Yes</td> +<td>Returns FALSE if the form element is not within a predetermined list.</td> +<td>in_list[red,blue,green]</td> +</tr> +<tr class="row-odd"><td><strong>alpha</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than alphabetical characters.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>alpha_numeric</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than alpha-numeric characters.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>alpha_numeric_spaces</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than alpha-numeric characters +or spaces. Should be used after trim to avoid spaces at the beginning or end.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>alpha_dash</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than alpha-numeric characters, +underscores or dashes.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>numeric</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than numeric characters.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>integer</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than an integer.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>decimal</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than a decimal number.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>is_natural</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than a natural number: +0, 1, 2, 3, etc.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>is_natural_no_zero</strong></td> +<td>No</td> +<td>Returns FALSE if the form element contains anything other than a natural +number, but not zero: 1, 2, 3, etc.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>valid_url</strong></td> +<td>No</td> +<td>Returns FALSE if the form element does not contain a valid URL.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>valid_email</strong></td> +<td>No</td> +<td>Returns FALSE if the form element does not contain a valid email address.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>valid_emails</strong></td> +<td>No</td> +<td>Returns FALSE if any value provided in a comma separated list is not a valid email.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>valid_ip</strong></td> +<td>Yes</td> +<td>Returns FALSE if the supplied IP address is not valid. +Accepts an optional parameter of ‘ipv4’ or ‘ipv6’ to specify an IP format.</td> +<td> </td> +</tr> +<tr class="row-even"><td><strong>valid_base64</strong></td> +<td>No</td> +<td>Returns FALSE if the supplied string contains anything other than valid Base64 characters.</td> +<td> </td> +</tr> +</tbody> +</table> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p>These rules can also be called as discrete methods. For +example:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">form_validation</span><span class="o">-></span><span class="na">required</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You can also use any native PHP functions that permit up +to two parameters, where at least one is required (to pass +the field data).</p> +</div> +</div> +<div class="section" id="prepping-reference"> +<h2><a class="toc-backref" href="#id33">Prepping Reference</a><a class="headerlink" href="#prepping-reference" title="Permalink to this headline">¶</a></h2> +<p>The following is a list of all the prepping methods that are available +to use:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="14%" /> +<col width="6%" /> +<col width="79%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Name</th> +<th class="head">Parameter</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>prep_for_form</strong></td> +<td>No</td> +<td>DEPRECATED: Converts special characters so that HTML data can be shown in a form field without breaking it.</td> +</tr> +<tr class="row-odd"><td><strong>prep_url</strong></td> +<td>No</td> +<td>Adds “http://” to URLs if missing.</td> +</tr> +<tr class="row-even"><td><strong>strip_image_tags</strong></td> +<td>No</td> +<td>Strips the HTML from image tags leaving the raw URL.</td> +</tr> +<tr class="row-odd"><td><strong>encode_php_tags</strong></td> +<td>No</td> +<td>Converts PHP tags to entities.</td> +</tr> +</tbody> +</table> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You can also use any native PHP functions that permits one +parameter, like <code class="docutils literal"><span class="pre">trim()</span></code>, <code class="docutils literal"><span class="pre">htmlspecialchars()</span></code>, <code class="docutils literal"><span class="pre">urldecode()</span></code>, +etc.</p> +</div> +</div> +<div class="section" id="class-reference"> +<span id="id5"></span><h2><a class="toc-backref" href="#id34">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Form_validation"> +<em class="property">class </em><code class="descname">CI_Form_validation</code><a class="headerlink" href="#CI_Form_validation" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Form_validation::set_rules"> +<code class="descname">set_rules</code><span class="sig-paren">(</span><em>$field</em><span class="optional">[</span>, <em>$label = ''</em><span class="optional">[</span>, <em>$rules = ''</em><span class="optional">[</span>, <em>$errors = array()</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::set_rules" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$field</strong> (<em>string</em>) – Field name</li> +<li><strong>$label</strong> (<em>string</em>) – Field label</li> +<li><strong>$rules</strong> (<em>mixed</em>) – Validation rules, as a string list separated by a pipe “|”, or as an array or rules</li> +<li><strong>$errors</strong> (<em>array</em>) – A list of custom error messages</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Form_validation instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Form_validation</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set validation rules, as described in the tutorial +sections above:</p> +<ul class="simple"> +<li><a class="reference internal" href="#setting-validation-rules"><span class="std std-ref">Setting Validation Rules</span></a></li> +<li><a class="reference internal" href="#saving-groups"><span class="std std-ref">Saving Sets of Validation Rules to a Config File</span></a></li> +</ul> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::run"> +<code class="descname">run</code><span class="sig-paren">(</span><span class="optional">[</span><em>$group = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::run" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$group</strong> (<em>string</em>) – The name of the validation group to run</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE if validation failed</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Runs the validation routines. Returns boolean TRUE on success and FALSE +on failure. You can optionally pass the name of the validation group via +the method, as described in: <a class="reference internal" href="#saving-groups"><span class="std std-ref">Saving Sets of Validation Rules to a Config File</span></a></p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::set_message"> +<code class="descname">set_message</code><span class="sig-paren">(</span><em>$lang</em><span class="optional">[</span>, <em>$val = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::set_message" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$lang</strong> (<em>string</em>) – The rule the message is for</li> +<li><strong>$val</strong> (<em>string</em>) – The message</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Form_validation instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Form_validation</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set custom error messages. See <a class="reference internal" href="#setting-error-messages"><span class="std std-ref">Setting Error Messages</span></a></p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::set_error_delimiters"> +<code class="descname">set_error_delimiters</code><span class="sig-paren">(</span><span class="optional">[</span><em>$prefix = '<p>'</em><span class="optional">[</span>, <em>$suffix = '</p>'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::set_error_delimiters" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$prefix</strong> (<em>string</em>) – Error message prefix</li> +<li><strong>$suffix</strong> (<em>string</em>) – Error message suffix</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Form_validation instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Form_validation</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the default prefix and suffix for error messages.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::set_data"> +<code class="descname">set_data</code><span class="sig-paren">(</span><em>$data</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::set_data" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>array</em>) – Array of data validate</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Form_validation instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Form_validation</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set an array for validation, instead of using the default +<code class="docutils literal"><span class="pre">$_POST</span></code> array.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::reset_validation"> +<code class="descname">reset_validation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::reset_validation" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">CI_Form_validation instance (method chaining)</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">CI_Form_validation</td> +</tr> +</tbody> +</table> +<p>Permits you to reset the validation when you validate more than one array. +This method should be called before validating each new array.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::error_array"> +<code class="descname">error_array</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::error_array" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array of error messages</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Returns the error messages as an array.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::error_string"> +<code class="descname">error_string</code><span class="sig-paren">(</span><span class="optional">[</span><em>$prefix = ''</em><span class="optional">[</span>, <em>$suffix = ''</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::error_string" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$prefix</strong> (<em>string</em>) – Error message prefix</li> +<li><strong>$suffix</strong> (<em>string</em>) – Error message suffix</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Error messages as a string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns all error messages (as returned from error_array()) formatted as a +string and separated by a newline character.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::error"> +<code class="descname">error</code><span class="sig-paren">(</span><em>$field</em><span class="optional">[</span>, <em>$prefix = ''</em><span class="optional">[</span>, <em>$suffix = ''</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::error" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$field</strong> (<em>string</em>) – Field name</li> +<li><strong>$prefix</strong> (<em>string</em>) – Optional prefix</li> +<li><strong>$suffix</strong> (<em>string</em>) – Optional suffix</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Error message string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns the error message for a specific field, optionally adding a +prefix and/or suffix to it (usually HTML tags).</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Form_validation::has_rule"> +<code class="descname">has_rule</code><span class="sig-paren">(</span><em>$field</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Form_validation::has_rule" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$field</strong> (<em>string</em>) – Field name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the field has rules set, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Checks to see if there is a rule set for the specified field.</p> +</dd></dl> + +</dd></dl> + +</div> +<div class="section" id="helper-reference"> +<span id="helper-functions"></span><h2><a class="toc-backref" href="#id35">Helper Reference</a><a class="headerlink" href="#helper-reference" title="Permalink to this headline">¶</a></h2> +<p>Please refer to the <a class="reference internal" href="../helpers/form_helper.html"><span class="doc">Form Helper</span></a> manual for +the following functions:</p> +<ul class="simple"> +<li><a class="reference internal" href="../helpers/form_helper.html#form_error" title="form_error"><code class="xref php php-func docutils literal"><span class="pre">form_error()</span></code></a></li> +<li><a class="reference internal" href="../helpers/form_helper.html#validation_errors" title="validation_errors"><code class="xref php php-func docutils literal"><span class="pre">validation_errors()</span></code></a></li> +<li><a class="reference internal" href="../helpers/form_helper.html#set_value" title="set_value"><code class="xref php php-func docutils literal"><span class="pre">set_value()</span></code></a></li> +<li><a class="reference internal" href="../helpers/form_helper.html#set_select" title="set_select"><code class="xref php php-func docutils literal"><span class="pre">set_select()</span></code></a></li> +<li><a class="reference internal" href="../helpers/form_helper.html#set_checkbox" title="set_checkbox"><code class="xref php php-func docutils literal"><span class="pre">set_checkbox()</span></code></a></li> +<li><a class="reference internal" href="../helpers/form_helper.html#set_radio" title="set_radio"><code class="xref php php-func docutils literal"><span class="pre">set_radio()</span></code></a></li> +</ul> +<p>Note that these are procedural functions, so they <strong>do not</strong> require you +to prepend them with <code class="docutils literal"><span class="pre">$this->form_validation</span></code>.</p> +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="ftp.html" class="btn btn-neutral float-right" title="FTP Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="file_uploading.html" class="btn btn-neutral" title="File Uploading Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/ftp.html b/user_guide/libraries/ftp.html new file mode 100644 index 000000000..0d786fbf0 --- /dev/null +++ b/user_guide/libraries/ftp.html @@ -0,0 +1,1016 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>FTP Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Image Manipulation Class" href="image_lib.html"/> + <link rel="prev" title="Form Validation" href="form_validation.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>FTP Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="ftp-class"> +<h1>FTP Class<a class="headerlink" href="#ftp-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s FTP Class permits files to be transferred to a remote +server. Remote files can also be moved, renamed, and deleted. The FTP +class also includes a “mirroring” function that permits an entire local +directory to be recreated remotely via FTP.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">SFTP and SSL FTP protocols are not supported, only standard +FTP.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#working-with-the-ftp-class" id="id1">Working with the FTP Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#usage-examples" id="id3">Usage Examples</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id4">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="working-with-the-ftp-class"> +<h2><a class="toc-backref" href="#id1">Working with the FTP Class</a><a class="headerlink" href="#working-with-the-ftp-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the FTP class is initialized in +your controller using the $this->load->library function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'ftp'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the FTP object will be available using: $this->ftp</p> +</div> +<div class="section" id="usage-examples"> +<h3><a class="toc-backref" href="#id3">Usage Examples</a><a class="headerlink" href="#usage-examples" title="Permalink to this headline">¶</a></h3> +<p>In this example a connection is opened to the FTP server, and a local +file is read and uploaded in ASCII mode. The file permissions are set to +755.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'ftp'</span><span class="p">);</span> + +<span class="nv">$config</span><span class="p">[</span><span class="s1">'hostname'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ftp.example.com'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'username'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-username'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'password'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-password'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'debug'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">connect</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">upload</span><span class="p">(</span><span class="s1">'/local/path/to/myfile.html'</span><span class="p">,</span> <span class="s1">'/public_html/myfile.html'</span><span class="p">,</span> <span class="s1">'ascii'</span><span class="p">,</span> <span class="mo">0775</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">close</span><span class="p">();</span> +</pre></div> +</div> +<p>In this example a list of files is retrieved from the server.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'ftp'</span><span class="p">);</span> + +<span class="nv">$config</span><span class="p">[</span><span class="s1">'hostname'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ftp.example.com'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'username'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-username'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'password'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-password'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'debug'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">connect</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="nv">$list</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">list_files</span><span class="p">(</span><span class="s1">'/public_html/'</span><span class="p">);</span> + +<span class="nb">print_r</span><span class="p">(</span><span class="nv">$list</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">close</span><span class="p">();</span> +</pre></div> +</div> +<p>In this example a local directory is mirrored on the server.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'ftp'</span><span class="p">);</span> + +<span class="nv">$config</span><span class="p">[</span><span class="s1">'hostname'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ftp.example.com'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'username'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-username'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'password'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-password'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'debug'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">connect</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">mirror</span><span class="p">(</span><span class="s1">'/path/to/myfolder/'</span><span class="p">,</span> <span class="s1">'/public_html/myfolder/'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">close</span><span class="p">();</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id4">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_FTP"> +<em class="property">class </em><code class="descname">CI_FTP</code><a class="headerlink" href="#CI_FTP" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_FTP::connect"> +<code class="descname">connect</code><span class="sig-paren">(</span><span class="optional">[</span><em>$config = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::connect" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$config</strong> (<em>array</em>) – Connection values</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Connects and logs into to the FTP server. Connection preferences are set +by passing an array to the function, or you can store them in a config +file.</p> +<p>Here is an example showing how you set preferences manually:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'ftp'</span><span class="p">);</span> + +<span class="nv">$config</span><span class="p">[</span><span class="s1">'hostname'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ftp.example.com'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'username'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-username'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'password'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'your-password'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'port'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">21</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'passive'</span><span class="p">]</span> <span class="o">=</span> <span class="k">FALSE</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'debug'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">connect</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> +</pre></div> +</div> +<p><strong>Setting FTP Preferences in a Config File</strong></p> +<p>If you prefer you can store your FTP preferences in a config file. +Simply create a new file called the ftp.php, add the $config array in +that file. Then save the file at <em>application/config/ftp.php</em> and it +will be used automatically.</p> +<p><strong>Available connection options</strong></p> +<table border="1" class="docutils"> +<colgroup> +<col width="13%" /> +<col width="14%" /> +<col width="73%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Option name</th> +<th class="head">Default value</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>hostname</strong></td> +<td>n/a</td> +<td>FTP hostname (usually something like: ftp.example.com)</td> +</tr> +<tr class="row-odd"><td><strong>username</strong></td> +<td>n/a</td> +<td>FTP username</td> +</tr> +<tr class="row-even"><td><strong>password</strong></td> +<td>n/a</td> +<td>FTP password</td> +</tr> +<tr class="row-odd"><td><strong>port</strong></td> +<td>21</td> +<td>FTP server port number</td> +</tr> +<tr class="row-even"><td><strong>debug</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean): Whether to enable debugging to display error messages</td> +</tr> +<tr class="row-odd"><td><strong>passive</strong></td> +<td>TRUE</td> +<td>TRUE/FALSE (boolean): Whether to use passive mode</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::upload"> +<code class="descname">upload</code><span class="sig-paren">(</span><em>$locpath</em>, <em>$rempath</em><span class="optional">[</span>, <em>$mode = 'auto'</em><span class="optional">[</span>, <em>$permissions = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::upload" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$locpath</strong> (<em>string</em>) – Local file path</li> +<li><strong>$rempath</strong> (<em>string</em>) – Remote file path</li> +<li><strong>$mode</strong> (<em>string</em>) – FTP mode, defaults to ‘auto’ (options are: ‘auto’, ‘binary’, ‘ascii’)</li> +<li><strong>$permissions</strong> (<em>int</em>) – File permissions (octal)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Uploads a file to your server. You must supply the local path and the +remote path, and you can optionally set the mode and permissions. +Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">upload</span><span class="p">(</span><span class="s1">'/local/path/to/myfile.html'</span><span class="p">,</span> <span class="s1">'/public_html/myfile.html'</span><span class="p">,</span> <span class="s1">'ascii'</span><span class="p">,</span> <span class="mo">0775</span><span class="p">);</span> +</pre></div> +</div> +<p>If ‘auto’ mode is used it will base the mode on the file extension of the source file.</p> +<p>If set, permissions have to be passed as an octal value.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::download"> +<code class="descname">download</code><span class="sig-paren">(</span><em>$rempath</em>, <em>$locpath</em><span class="optional">[</span>, <em>$mode = 'auto'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::download" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$rempath</strong> (<em>string</em>) – Remote file path</li> +<li><strong>$locpath</strong> (<em>string</em>) – Local file path</li> +<li><strong>$mode</strong> (<em>string</em>) – FTP mode, defaults to ‘auto’ (options are: ‘auto’, ‘binary’, ‘ascii’)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Downloads a file from your server. You must supply the remote path and +the local path, and you can optionally set the mode. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'/public_html/myfile.html'</span><span class="p">,</span> <span class="s1">'/local/path/to/myfile.html'</span><span class="p">,</span> <span class="s1">'ascii'</span><span class="p">);</span> +</pre></div> +</div> +<p>If ‘auto’ mode is used it will base the mode on the file extension of the source file.</p> +<p>Returns FALSE if the download does not execute successfully +(including if PHP does not have permission to write the local file).</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::rename"> +<code class="descname">rename</code><span class="sig-paren">(</span><em>$old_file</em>, <em>$new_file</em><span class="optional">[</span>, <em>$move = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::rename" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$old_file</strong> (<em>string</em>) – Old file name</li> +<li><strong>$new_file</strong> (<em>string</em>) – New file name</li> +<li><strong>$move</strong> (<em>bool</em>) – Whether a move is being performed</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to rename a file. Supply the source file name/path and the new file name/path.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Renames green.html to blue.html</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">rename</span><span class="p">(</span><span class="s1">'/public_html/foo/green.html'</span><span class="p">,</span> <span class="s1">'/public_html/foo/blue.html'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::move"> +<code class="descname">move</code><span class="sig-paren">(</span><em>$old_file</em>, <em>$new_file</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::move" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$old_file</strong> (<em>string</em>) – Old file name</li> +<li><strong>$new_file</strong> (<em>string</em>) – New file name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you move a file. Supply the source and destination paths:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Moves blog.html from "joe" to "fred"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">move</span><span class="p">(</span><span class="s1">'/public_html/joe/blog.html'</span><span class="p">,</span> <span class="s1">'/public_html/fred/blog.html'</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If the destination file name is different the file will be renamed.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::delete_file"> +<code class="descname">delete_file</code><span class="sig-paren">(</span><em>$filepath</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::delete_file" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filepath</strong> (<em>string</em>) – Path to file to delete</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you delete a file. Supply the source path with the file name.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">delete_file</span><span class="p">(</span><span class="s1">'/public_html/joe/blog.html'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::delete_dir"> +<code class="descname">delete_dir</code><span class="sig-paren">(</span><em>$filepath</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::delete_dir" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filepath</strong> (<em>string</em>) – Path to directory to delete</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you delete a directory and everything it contains. Supply the +source path to the directory with a trailing slash.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Be VERY careful with this method! +It will recursively delete <strong>everything</strong> within the supplied path, +including sub-folders and all files. Make absolutely sure your path +is correct. Try using <code class="docutils literal"><span class="pre">list_files()</span></code> first to verify that your path is correct.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">delete_dir</span><span class="p">(</span><span class="s1">'/public_html/path/to/folder/'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::list_files"> +<code class="descname">list_files</code><span class="sig-paren">(</span><span class="optional">[</span><em>$path = '.'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::list_files" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Directory path</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An array list of files or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to retrieve a list of files on your server returned as an +array. You must supply the path to the desired directory.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$list</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">list_files</span><span class="p">(</span><span class="s1">'/public_html/'</span><span class="p">);</span> +<span class="nb">print_r</span><span class="p">(</span><span class="nv">$list</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::mirror"> +<code class="descname">mirror</code><span class="sig-paren">(</span><em>$locpath</em>, <em>$rempath</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::mirror" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$locpath</strong> (<em>string</em>) – Local path</li> +<li><strong>$rempath</strong> (<em>string</em>) – Remote path</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Recursively reads a local folder and everything it contains (including +sub-folders) and creates a mirror via FTP based on it. Whatever the +directory structure of the original file path will be recreated on the +server. You must supply a source path and a destination path:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">mirror</span><span class="p">(</span><span class="s1">'/path/to/myfolder/'</span><span class="p">,</span> <span class="s1">'/public_html/myfolder/'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::mkdir"> +<code class="descname">mkdir</code><span class="sig-paren">(</span><em>$path</em><span class="optional">[</span>, <em>$permissions = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::mkdir" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Path to directory to create</li> +<li><strong>$permissions</strong> (<em>int</em>) – Permissions (octal)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you create a directory on your server. Supply the path ending in +the folder name you wish to create, with a trailing slash.</p> +<p>Permissions can be set by passing an octal value in the second parameter.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Creates a folder named "bar"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">mkdir</span><span class="p">(</span><span class="s1">'/public_html/foo/bar/'</span><span class="p">,</span> <span class="mo">0755</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::chmod"> +<code class="descname">chmod</code><span class="sig-paren">(</span><em>$path</em>, <em>$perm</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::chmod" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Path to alter permissions for</li> +<li><strong>$perm</strong> (<em>int</em>) – Permissions (octal)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set file permissions. Supply the path to the file or +directory you wish to alter permissions on:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Chmod "bar" to 755</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">ftp</span><span class="o">-></span><span class="na">chmod</span><span class="p">(</span><span class="s1">'/public_html/foo/bar/'</span><span class="p">,</span> <span class="mo">0755</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::changedir"> +<code class="descname">changedir</code><span class="sig-paren">(</span><em>$path</em><span class="optional">[</span>, <em>$suppress_debug = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::changedir" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Directory path</li> +<li><strong>$suppress_debug</strong> (<em>bool</em>) – Whether to turn off debug messages for this command</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Changes the current working directory to the specified path.</p> +<p>The <code class="docutils literal"><span class="pre">$suppress_debug</span></code> parameter is useful in case you want to use this method +as an <code class="docutils literal"><span class="pre">is_dir()</span></code> alternative for FTP.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_FTP::close"> +<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_FTP::close" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>Closes the connection to your server. It’s recommended that you use this +when you are finished uploading.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="image_lib.html" class="btn btn-neutral float-right" title="Image Manipulation Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="form_validation.html" class="btn btn-neutral" title="Form Validation"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/image_lib.html b/user_guide/libraries/image_lib.html new file mode 100644 index 000000000..9c2bc7c55 --- /dev/null +++ b/user_guide/libraries/image_lib.html @@ -0,0 +1,1255 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Image Manipulation Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Input Class" href="input.html"/> + <link rel="prev" title="FTP Class" href="ftp.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Image Manipulation Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="image-manipulation-class"> +<h1>Image Manipulation Class<a class="headerlink" href="#image-manipulation-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s Image Manipulation class lets you perform the following +actions:</p> +<ul class="simple"> +<li>Image Resizing</li> +<li>Thumbnail Creation</li> +<li>Image Cropping</li> +<li>Image Rotating</li> +<li>Image Watermarking</li> +</ul> +<p>All three major image libraries are supported: GD/GD2, NetPBM, and +ImageMagick</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Watermarking is only available using the GD/GD2 library. In +addition, even though other libraries are supported, GD is required in +order for the script to calculate the image properties. The image +processing, however, will be performed with the library you specify.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#initializing-the-class" id="id1">Initializing the Class</a><ul> +<li><a class="reference internal" href="#processing-an-image" id="id2">Processing an Image</a></li> +<li><a class="reference internal" href="#processing-methods" id="id3">Processing Methods</a></li> +<li><a class="reference internal" href="#preferences" id="id4">Preferences</a></li> +<li><a class="reference internal" href="#setting-preferences-in-a-config-file" id="id5">Setting preferences in a config file</a></li> +</ul> +</li> +<li><a class="reference internal" href="#image-watermarking" id="id6">Image Watermarking</a><ul> +<li><a class="reference internal" href="#two-types-of-watermarking" id="id7">Two Types of Watermarking</a></li> +<li><a class="reference internal" href="#watermarking-an-image" id="id8">Watermarking an Image</a></li> +<li><a class="reference internal" href="#watermarking-preferences" id="id9">Watermarking Preferences</a><ul> +<li><a class="reference internal" href="#text-preferences" id="id10">Text Preferences</a></li> +<li><a class="reference internal" href="#overlay-preferences" id="id11">Overlay Preferences</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id12">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="initializing-the-class"> +<h2><a class="toc-backref" href="#id1">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h2> +<p>Like most other classes in CodeIgniter, the image class is initialized +in your controller using the $this->load->library function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'image_lib'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once the library is loaded it will be ready for use. The image library +object you will use to call all functions is: <code class="docutils literal"><span class="pre">$this->image_lib</span></code></p> +<div class="section" id="processing-an-image"> +<h3><a class="toc-backref" href="#id2">Processing an Image</a><a class="headerlink" href="#processing-an-image" title="Permalink to this headline">¶</a></h3> +<p>Regardless of the type of processing you would like to perform +(resizing, cropping, rotation, or watermarking), the general process is +identical. You will set some preferences corresponding to the action you +intend to perform, then call one of four available processing functions. +For example, to create an image thumbnail you’ll do this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'image_library'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'gd2'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'create_thumb'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'maintain_ratio'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'width'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">75</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'height'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">50</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'image_lib'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">resize</span><span class="p">();</span> +</pre></div> +</div> +<p>The above code tells the image_resize function to look for an image +called <em>mypic.jpg</em> located in the source_image folder, then create a +thumbnail that is 75 X 50 pixels using the GD2 image_library. Since the +maintain_ratio option is enabled, the thumb will be as close to the +target width and height as possible while preserving the original aspect +ratio. The thumbnail will be called <em>mypic_thumb.jpg</em> and located at +the same level as <em>source_image</em>.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In order for the image class to be allowed to do any +processing, the folder containing the image files must have write +permissions.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Image processing can require a considerable amount of server +memory for some operations. If you are experiencing out of memory errors +while processing images you may need to limit their maximum size, and/or +adjust PHP memory limits.</p> +</div> +</div> +<div class="section" id="processing-methods"> +<h3><a class="toc-backref" href="#id3">Processing Methods</a><a class="headerlink" href="#processing-methods" title="Permalink to this headline">¶</a></h3> +<p>There are four available processing methods:</p> +<ul class="simple"> +<li>$this->image_lib->resize()</li> +<li>$this->image_lib->crop()</li> +<li>$this->image_lib->rotate()</li> +<li>$this->image_lib->watermark()</li> +</ul> +<p>These methods return boolean TRUE upon success and FALSE for failure. +If they fail you can retrieve the error message using this function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +</pre></div> +</div> +<p>A good practice is to use the processing function conditionally, showing an +error upon failure, like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">resize</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p>You can optionally specify the HTML formatting to be applied to +the errors, by submitting the opening/closing tags in the function, +like this:</p> +<div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">(</span><span class="s1">'<p>'</span><span class="p">,</span> <span class="s1">'</p>'</span><span class="p">);</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="preferences"> +<span id="processing-preferences"></span><h3><a class="toc-backref" href="#id4">Preferences</a><a class="headerlink" href="#preferences" title="Permalink to this headline">¶</a></h3> +<p>The preferences described below allow you to tailor the image processing +to suit your needs.</p> +<p>Note that not all preferences are available for every function. For +example, the x/y axis preferences are only available for image cropping. +Likewise, the width and height preferences have no effect on cropping. +The “availability” column indicates which functions support a given +preference.</p> +<p>Availability Legend:</p> +<ul class="simple"> +<li>R - Image Resizing</li> +<li>C - Image Cropping</li> +<li>X - Image Rotation</li> +<li>W - Image Watermarking</li> +</ul> +<table border="1" class="docutils"> +<colgroup> +<col width="14%" /> +<col width="14%" /> +<col width="19%" /> +<col width="45%" /> +<col width="8%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default Value</th> +<th class="head">Options</th> +<th class="head">Description</th> +<th class="head">Availability</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>image_library</strong></td> +<td>GD2</td> +<td>GD, GD2, ImageMagick, NetPBM</td> +<td>Sets the image library to be used.</td> +<td>R, C, X, W</td> +</tr> +<tr class="row-odd"><td><strong>library_path</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the server path to your ImageMagick or NetPBM library. If you use +either of those libraries you must supply the path.</td> +<td>R, C, X +R, C, S, W</td> +</tr> +<tr class="row-even"><td><strong>source_image</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the source image name/path. The path must be a relative or absolute +server path, not a URL.</td> +<td> </td> +</tr> +<tr class="row-odd"><td><strong>dynamic_output</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>Determines whether the new image file should be written to disk or +generated dynamically. Note: If you choose the dynamic setting, only one +image can be shown at a time, and it can’t be positioned on the page. It +simply outputs the raw image dynamically to your browser, along with +image headers.</td> +<td>R, C, X, W</td> +</tr> +<tr class="row-even"><td><strong>file_permissions</strong></td> +<td>0644</td> +<td>(integer)</td> +<td>File system permissions to apply on the resulting image file, +writing it to the disk. WARNING: Use octal integer notation!</td> +<td>R, C, X, W</td> +</tr> +<tr class="row-odd"><td><strong>quality</strong></td> +<td>90%</td> +<td>1 - 100%</td> +<td>Sets the quality of the image. The higher the quality the larger the +file size.</td> +<td>R, C, X, W</td> +</tr> +<tr class="row-even"><td><strong>new_image</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the destination image name/path. You’ll use this preference when +creating an image copy. The path must be a relative or absolute server +path, not a URL.</td> +<td>R, C, X, W</td> +</tr> +<tr class="row-odd"><td><strong>width</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the width you would like the image set to.</td> +<td>R, C</td> +</tr> +<tr class="row-even"><td><strong>height</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the height you would like the image set to.</td> +<td>R, C</td> +</tr> +<tr class="row-odd"><td><strong>create_thumb</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>Tells the image processing function to create a thumb.</td> +<td>R</td> +</tr> +<tr class="row-even"><td><strong>thumb_marker</strong></td> +<td>_thumb</td> +<td>None</td> +<td>Specifies the thumbnail indicator. It will be inserted just before the +file extension, so mypic.jpg would become mypic_thumb.jpg</td> +<td>R</td> +</tr> +<tr class="row-odd"><td><strong>maintain_ratio</strong></td> +<td>TRUE</td> +<td>TRUE/FALSE (boolean)</td> +<td>Specifies whether to maintain the original aspect ratio when resizing or +use hard values.</td> +<td>R, C</td> +</tr> +<tr class="row-even"><td><strong>master_dim</strong></td> +<td>auto</td> +<td>auto, width, height</td> +<td>Specifies what to use as the master axis when resizing or creating +thumbs. For example, let’s say you want to resize an image to 100 X 75 +pixels. If the source image size does not allow perfect resizing to +those dimensions, this setting determines which axis should be used as +the hard value. “auto” sets the axis automatically based on whether the +image is taller than wider, or vice versa.</td> +<td>R</td> +</tr> +<tr class="row-odd"><td><strong>rotation_angle</strong></td> +<td>None</td> +<td>90, 180, 270, vrt, hor</td> +<td>Specifies the angle of rotation when rotating images. Note that PHP +rotates counter-clockwise, so a 90 degree rotation to the right must be +specified as 270.</td> +<td>X</td> +</tr> +<tr class="row-even"><td><strong>x_axis</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the X coordinate in pixels for image cropping. For example, a +setting of 30 will crop an image 30 pixels from the left.</td> +<td>C</td> +</tr> +<tr class="row-odd"><td><strong>y_axis</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the Y coordinate in pixels for image cropping. For example, a +setting of 30 will crop an image 30 pixels from the top.</td> +<td>C</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="setting-preferences-in-a-config-file"> +<h3><a class="toc-backref" href="#id5">Setting preferences in a config file</a><a class="headerlink" href="#setting-preferences-in-a-config-file" title="Permalink to this headline">¶</a></h3> +<p>If you prefer not to set preferences using the above method, you can +instead put them into a config file. Simply create a new file called +image_lib.php, add the $config array in that file. Then save the file +in <em>config/image_lib.php</em> and it will be used automatically. You will +NOT need to use the <code class="docutils literal"><span class="pre">$this->image_lib->initialize()</span></code> method if you save +your preferences in a config file.</p> +</div> +</div> +<div class="section" id="image-watermarking"> +<h2><a class="toc-backref" href="#id6">Image Watermarking</a><a class="headerlink" href="#image-watermarking" title="Permalink to this headline">¶</a></h2> +<p>The Watermarking feature requires the GD/GD2 library.</p> +<div class="section" id="two-types-of-watermarking"> +<h3><a class="toc-backref" href="#id7">Two Types of Watermarking</a><a class="headerlink" href="#two-types-of-watermarking" title="Permalink to this headline">¶</a></h3> +<p>There are two types of watermarking that you can use:</p> +<ul class="simple"> +<li><strong>Text</strong>: The watermark message will be generated using text, either +with a True Type font that you specify, or using the native text +output that the GD library supports. If you use the True Type version +your GD installation must be compiled with True Type support (most +are, but not all).</li> +<li><strong>Overlay</strong>: The watermark message will be generated by overlaying an +image (usually a transparent PNG or GIF) containing your watermark +over the source image.</li> +</ul> +</div> +<div class="section" id="watermarking-an-image"> +<span id="watermarking"></span><h3><a class="toc-backref" href="#id8">Watermarking an Image</a><a class="headerlink" href="#watermarking-an-image" title="Permalink to this headline">¶</a></h3> +<p>Just as with the other methods (resizing, cropping, and rotating) the +general process for watermarking involves setting the preferences +corresponding to the action you intend to perform, then calling the +watermark function. Here is an example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_text'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'Copyright 2006 - John Doe'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_type'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'text'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_font_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'./system/fonts/texb.ttf'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_font_size'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'16'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_font_color'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ffffff'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_vrt_alignment'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'bottom'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_hor_alignment'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'center'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_padding'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'20'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">watermark</span><span class="p">();</span> +</pre></div> +</div> +<p>The above example will use a 16 pixel True Type font to create the text +“Copyright 2006 - John Doe”. The watermark will be positioned at the +bottom/center of the image, 20 pixels from the bottom of the image.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In order for the image class to be allowed to do any +processing, the image file must have “write” file permissions +For example, 777.</p> +</div> +</div> +<div class="section" id="watermarking-preferences"> +<h3><a class="toc-backref" href="#id9">Watermarking Preferences</a><a class="headerlink" href="#watermarking-preferences" title="Permalink to this headline">¶</a></h3> +<p>This table shows the preferences that are available for both types of +watermarking (text or overlay)</p> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="14%" /> +<col width="17%" /> +<col width="53%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default Value</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>wm_type</strong></td> +<td>text</td> +<td>text, overlay</td> +<td>Sets the type of watermarking that should be used.</td> +</tr> +<tr class="row-odd"><td><strong>source_image</strong></td> +<td>None</td> +<td>None</td> +<td>Sets the source image name/path. The path must be a relative or absolute +server path, not a URL.</td> +</tr> +<tr class="row-even"><td><strong>dynamic_output</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>Determines whether the new image file should be written to disk or +generated dynamically. Note: If you choose the dynamic setting, only one +image can be shown at a time, and it can’t be positioned on the page. It +simply outputs the raw image dynamically to your browser, along with +image headers.</td> +</tr> +<tr class="row-odd"><td><strong>quality</strong></td> +<td>90%</td> +<td>1 - 100%</td> +<td>Sets the quality of the image. The higher the quality the larger the +file size.</td> +</tr> +<tr class="row-even"><td><strong>wm_padding</strong></td> +<td>None</td> +<td>A number</td> +<td>The amount of padding, set in pixels, that will be applied to the +watermark to set it away from the edge of your images.</td> +</tr> +<tr class="row-odd"><td><strong>wm_vrt_alignment</strong></td> +<td>bottom</td> +<td>top, middle, bottom</td> +<td>Sets the vertical alignment for the watermark image.</td> +</tr> +<tr class="row-even"><td><strong>wm_hor_alignment</strong></td> +<td>center</td> +<td>left, center, right</td> +<td>Sets the horizontal alignment for the watermark image.</td> +</tr> +<tr class="row-odd"><td><strong>wm_hor_offset</strong></td> +<td>None</td> +<td>None</td> +<td>You may specify a horizontal offset (in pixels) to apply to the +watermark position. The offset normally moves the watermark to the +right, except if you have your alignment set to “right” then your offset +value will move the watermark toward the left of the image.</td> +</tr> +<tr class="row-even"><td><strong>wm_vrt_offset</strong></td> +<td>None</td> +<td>None</td> +<td>You may specify a vertical offset (in pixels) to apply to the watermark +position. The offset normally moves the watermark down, except if you +have your alignment set to “bottom” then your offset value will move the +watermark toward the top of the image.</td> +</tr> +</tbody> +</table> +<div class="section" id="text-preferences"> +<h4><a class="toc-backref" href="#id10">Text Preferences</a><a class="headerlink" href="#text-preferences" title="Permalink to this headline">¶</a></h4> +<p>This table shows the preferences that are available for the text type of +watermarking.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="14%" /> +<col width="14%" /> +<col width="55%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default Value</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>wm_text</strong></td> +<td>None</td> +<td>None</td> +<td>The text you would like shown as the watermark. Typically this will be a +copyright notice.</td> +</tr> +<tr class="row-odd"><td><strong>wm_font_path</strong></td> +<td>None</td> +<td>None</td> +<td>The server path to the True Type Font you would like to use. If you do +not use this option, the native GD font will be used.</td> +</tr> +<tr class="row-even"><td><strong>wm_font_size</strong></td> +<td>16</td> +<td>None</td> +<td>The size of the text. Note: If you are not using the True Type option +above, the number is set using a range of 1 - 5. Otherwise, you can use +any valid pixel size for the font you’re using.</td> +</tr> +<tr class="row-odd"><td><strong>wm_font_color</strong></td> +<td>ffffff</td> +<td>None</td> +<td>The font color, specified in hex. Both the full 6-length (ie, 993300) and +the short three character abbreviated version (ie, fff) are supported.</td> +</tr> +<tr class="row-even"><td><strong>wm_shadow_color</strong></td> +<td>None</td> +<td>None</td> +<td>The color of the drop shadow, specified in hex. If you leave this blank +a drop shadow will not be used. Both the full 6-length (ie, 993300) and +the short three character abbreviated version (ie, fff) are supported.</td> +</tr> +<tr class="row-odd"><td><strong>wm_shadow_distance</strong></td> +<td>3</td> +<td>None</td> +<td>The distance (in pixels) from the font that the drop shadow should +appear.</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="overlay-preferences"> +<h4><a class="toc-backref" href="#id11">Overlay Preferences</a><a class="headerlink" href="#overlay-preferences" title="Permalink to this headline">¶</a></h4> +<p>This table shows the preferences that are available for the overlay type +of watermarking.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="14%" /> +<col width="14%" /> +<col width="55%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default Value</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>wm_overlay_path</strong></td> +<td>None</td> +<td>None</td> +<td>The server path to the image you wish to use as your watermark. Required +only if you are using the overlay method.</td> +</tr> +<tr class="row-odd"><td><strong>wm_opacity</strong></td> +<td>50</td> +<td>1 - 100</td> +<td>Image opacity. You may specify the opacity (i.e. transparency) of your +watermark image. This allows the watermark to be faint and not +completely obscure the details from the original image behind it. A 50% +opacity is typical.</td> +</tr> +<tr class="row-even"><td><strong>wm_x_transp</strong></td> +<td>4</td> +<td>A number</td> +<td>If your watermark image is a PNG or GIF image, you may specify a color +on the image to be “transparent”. This setting (along with the next) +will allow you to specify that color. This works by specifying the “X” +and “Y” coordinate pixel (measured from the upper left) within the image +that corresponds to a pixel representative of the color you want to be +transparent.</td> +</tr> +<tr class="row-odd"><td><strong>wm_y_transp</strong></td> +<td>4</td> +<td>A number</td> +<td>Along with the previous setting, this allows you to specify the +coordinate to a pixel representative of the color you want to be +transparent.</td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id12">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Image_lib"> +<em class="property">class </em><code class="descname">CI_Image_lib</code><a class="headerlink" href="#CI_Image_lib" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Image_lib::initialize"> +<code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>$props = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::initialize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$props</strong> (<em>array</em>) – Image processing preferences</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE in case of invalid settings</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Initializes the class for processing an image.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Image_lib::resize"> +<code class="descname">resize</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::resize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>The image resizing method lets you resize the original image, create a +copy (with or without resizing), or create a thumbnail image.</p> +<p>For practical purposes there is no difference between creating a copy +and creating a thumbnail except a thumb will have the thumbnail marker +as part of the name (i.e. mypic_thumb.jpg).</p> +<p>All preferences listed in the <a class="reference internal" href="#processing-preferences"><span class="std std-ref">Preferences</span></a> table are available for this +method except these three: <em>rotation_angle</em>, <em>x_axis</em> and <em>y_axis</em>.</p> +<p><strong>Creating a Thumbnail</strong></p> +<p>The resizing method will create a thumbnail file (and preserve the +original) if you set this preference to TRUE:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'create_thumb'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +</pre></div> +</div> +<p>This single preference determines whether a thumbnail is created or not.</p> +<p><strong>Creating a Copy</strong></p> +<p>The resizing method will create a copy of the image file (and preserve +the original) if you set a path and/or a new filename using this +preference:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'new_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/new_image.jpg'</span><span class="p">;</span> +</pre></div> +</div> +<p>Notes regarding this preference:</p> +<ul class="simple"> +<li>If only the new image name is specified it will be placed in the same +folder as the original</li> +<li>If only the path is specified, the new image will be placed in the +destination with the same name as the original.</li> +<li>If both the path and image name are specified it will placed in its +own destination and given the new name.</li> +</ul> +<p><strong>Resizing the Original Image</strong></p> +<p>If neither of the two preferences listed above (create_thumb, and +new_image) are used, the resizing method will instead target the +original image for processing.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Image_lib::crop"> +<code class="descname">crop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::crop" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>The cropping method works nearly identically to the resizing function +except it requires that you set preferences for the X and Y axis (in +pixels) specifying where to crop, like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'x_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'y_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">40</span><span class="p">;</span> +</pre></div> +</div> +<p>All preferences listed in the <a class="reference internal" href="#processing-preferences"><span class="std std-ref">Preferences</span></a> table are available for this +method except these: <em>rotation_angle</em>, <em>create_thumb</em> and <em>new_image</em>.</p> +<p>Here’s an example showing how you might crop an image:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'image_library'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'imagemagick'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'library_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/usr/X11R6/bin/'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'x_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'y_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">60</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">crop</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Without a visual interface it is difficult to crop images, so this +method is not very useful unless you intend to build such an +interface. That’s exactly what we did using for the photo gallery module +in ExpressionEngine, the CMS we develop. We added a JavaScript UI that +lets the cropping area be selected.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Image_lib::rotate"> +<code class="descname">rotate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::rotate" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>The image rotation method requires that the angle of rotation be set +via its preference:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'rotation_angle'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'90'</span><span class="p">;</span> +</pre></div> +</div> +<p>There are 5 rotation options:</p> +<ol class="arabic simple"> +<li>90 - rotates counter-clockwise by 90 degrees.</li> +<li>180 - rotates counter-clockwise by 180 degrees.</li> +<li>270 - rotates counter-clockwise by 270 degrees.</li> +<li>hor - flips the image horizontally.</li> +<li>vrt - flips the image vertically.</li> +</ol> +<p>Here’s an example showing how you might rotate an image:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'image_library'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'netpbm'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'library_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/usr/bin/'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'rotation_angle'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'hor'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">rotate</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Image_lib::watermark"> +<code class="descname">watermark</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::watermark" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>Creates a watermark over an image, please refer to the <a class="reference internal" href="#watermarking"><span class="std std-ref">Watermarking an Image</span></a> +section for more info.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Image_lib::clear"> +<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::clear" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> +</tr> +</tbody> +</table> +<p>The clear method resets all of the values used when processing an +image. You will want to call this if you are processing images in a +loop.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">clear</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Image_lib::display_errors"> +<code class="descname">display_errors</code><span class="sig-paren">(</span><span class="optional">[</span><em>$open = '<p></em><span class="optional">[</span>, <em>$close = '</p>'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::display_errors" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$open</strong> (<em>string</em>) – Error message opening tag</li> +<li><strong>$close</strong> (<em>string</em>) – Error message closing tag</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Error messages</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns all detected errors formatted as a string.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="input.html" class="btn btn-neutral float-right" title="Input Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="ftp.html" class="btn btn-neutral" title="FTP Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/index.html b/user_guide/libraries/index.html new file mode 100644 index 000000000..7f74eccf5 --- /dev/null +++ b/user_guide/libraries/index.html @@ -0,0 +1,527 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Libraries — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="next" title="Benchmarking Class" href="benchmark.html"/> + <link rel="prev" title="PHP Style Guide" href="../general/styleguide.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="current reference internal" href="#">Libraries</a><ul> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="current reference internal" href="#">Libraries</a><ul> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li>Libraries</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="libraries"> +<h1>Libraries<a class="headerlink" href="#libraries" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l1"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l1"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l1"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l1"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l1"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l1"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="benchmark.html" class="btn btn-neutral float-right" title="Benchmarking Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../general/styleguide.html" class="btn btn-neutral" title="PHP Style Guide"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html new file mode 100644 index 000000000..3463c949a --- /dev/null +++ b/user_guide/libraries/input.html @@ -0,0 +1,1191 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Input Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Javascript Class" href="javascript.html"/> + <link rel="prev" title="Image Manipulation Class" href="image_lib.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Input Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="input-class"> +<h1>Input Class<a class="headerlink" href="#input-class" title="Permalink to this headline">¶</a></h1> +<p>The Input Class serves two purposes:</p> +<ol class="arabic simple"> +<li>It pre-processes global input data for security.</li> +<li>It provides some helper methods for fetching input data and pre-processing it.</li> +</ol> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This class is initialized automatically by the system so there +is no need to do it manually.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#input-filtering" id="id1">Input Filtering</a><ul> +<li><a class="reference internal" href="#security-filtering" id="id2">Security Filtering</a></li> +<li><a class="reference internal" href="#xss-filtering" id="id3">XSS Filtering</a></li> +</ul> +</li> +<li><a class="reference internal" href="#accessing-form-data" id="id4">Accessing form data</a><ul> +<li><a class="reference internal" href="#using-post-get-cookie-or-server-data" id="id5">Using POST, GET, COOKIE, or SERVER Data</a></li> +<li><a class="reference internal" href="#using-the-php-input-stream" id="id6">Using the php://input stream</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id7">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="input-filtering"> +<h2><a class="toc-backref" href="#id1">Input Filtering</a><a class="headerlink" href="#input-filtering" title="Permalink to this headline">¶</a></h2> +<div class="section" id="security-filtering"> +<h3><a class="toc-backref" href="#id2">Security Filtering</a><a class="headerlink" href="#security-filtering" title="Permalink to this headline">¶</a></h3> +<p>The security filtering method is called automatically when a new +<a class="reference internal" href="../general/controllers.html"><span class="doc">controller</span></a> is invoked. It does the +following:</p> +<ul class="simple"> +<li>If <code class="docutils literal"><span class="pre">$config['allow_get_array']</span></code> is FALSE (default is TRUE), destroys +the global GET array.</li> +<li>Destroys all global variables in the event register_globals is +turned on.</li> +<li>Filters the GET/POST/COOKIE array keys, permitting only alpha-numeric +(and a few other) characters.</li> +<li>Provides XSS (Cross-site Scripting Hacks) filtering. This can be +enabled globally, or upon request.</li> +<li>Standardizes newline characters to <code class="docutils literal"><span class="pre">PHP_EOL</span></code> (\n in UNIX-based OSes, +\r\n under Windows). This is configurable.</li> +</ul> +</div> +<div class="section" id="xss-filtering"> +<h3><a class="toc-backref" href="#id3">XSS Filtering</a><a class="headerlink" href="#xss-filtering" title="Permalink to this headline">¶</a></h3> +<p>The Input class has the ability to filter input automatically to prevent +cross-site scripting attacks. If you want the filter to run +automatically every time it encounters POST or COOKIE data you can +enable it by opening your <em>application/config/config.php</em> file and setting +this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'global_xss_filtering'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +</pre></div> +</div> +<p>Please refer to the <a class="reference internal" href="security.html"><span class="doc">Security class</span></a> documentation for +information on using XSS Filtering in your application.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The ‘global_xss_filtering’ setting is DEPRECATED and kept +solely for backwards-compatibility purposes. XSS escaping should +be performed on <em>output</em>, not <em>input</em>!</p> +</div> +</div> +</div> +<div class="section" id="accessing-form-data"> +<h2><a class="toc-backref" href="#id4">Accessing form data</a><a class="headerlink" href="#accessing-form-data" title="Permalink to this headline">¶</a></h2> +<div class="section" id="using-post-get-cookie-or-server-data"> +<h3><a class="toc-backref" href="#id5">Using POST, GET, COOKIE, or SERVER Data</a><a class="headerlink" href="#using-post-get-cookie-or-server-data" title="Permalink to this headline">¶</a></h3> +<p>CodeIgniter comes with helper methods that let you fetch POST, GET, +COOKIE or SERVER items. The main advantage of using the provided +methods rather than fetching an item directly (<code class="docutils literal"><span class="pre">$_POST['something']</span></code>) +is that the methods will check to see if the item is set and return +NULL if not. This lets you conveniently use data without +having to test whether an item exists first. In other words, normally +you might do something like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$something</span> <span class="o">=</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$_POST</span><span class="p">[</span><span class="s1">'something'</span><span class="p">])</span> <span class="o">?</span> <span class="nv">$_POST</span><span class="p">[</span><span class="s1">'something'</span><span class="p">]</span> <span class="o">:</span> <span class="k">NULL</span><span class="p">;</span> +</pre></div> +</div> +<p>With CodeIgniter’s built in methods you can simply do this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$something</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="s1">'something'</span><span class="p">);</span> +</pre></div> +</div> +<p>The main methods are:</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">$this->input->post()</span></code></li> +<li><code class="docutils literal"><span class="pre">$this->input->get()</span></code></li> +<li><code class="docutils literal"><span class="pre">$this->input->cookie()</span></code></li> +<li><code class="docutils literal"><span class="pre">$this->input->server()</span></code></li> +</ul> +</div> +<div class="section" id="using-the-php-input-stream"> +<h3><a class="toc-backref" href="#id6">Using the php://input stream</a><a class="headerlink" href="#using-the-php-input-stream" title="Permalink to this headline">¶</a></h3> +<p>If you want to utilize the PUT, DELETE, PATCH or other exotic request +methods, they can only be accessed via a special input stream, that +can only be read once. This isn’t as easy as just reading from e.g. +the <code class="docutils literal"><span class="pre">$_POST</span></code> array, because it will always exist and you can try +and access multiple variables without caring that you might only have +one shot at all of the POST data.</p> +<p>CodeIgniter will take care of that for you, and you can read the data +from the <strong>php://input</strong> stream at any time, just by using the +<code class="docutils literal"><span class="pre">$raw_input_stream</span></code> property:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">raw_input_stream</span><span class="p">;</span> +</pre></div> +</div> +<p>Additionally if the input stream is form-encoded like $_POST you can +access its values by calling the +<code class="docutils literal"><span class="pre">input_stream()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">input_stream</span><span class="p">(</span><span class="s1">'key'</span><span class="p">);</span> +</pre></div> +</div> +<p>Similar to other methods such as <code class="docutils literal"><span class="pre">get()</span></code> and <code class="docutils literal"><span class="pre">post()</span></code>, if the +requested data is not found, it will return NULL and you can also +decide whether to run the data through <code class="docutils literal"><span class="pre">xss_clean()</span></code> by passing +a boolean value as the second parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">input_stream</span><span class="p">(</span><span class="s1">'key'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> <span class="c1">// XSS Clean</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">input_stream</span><span class="p">(</span><span class="s1">'key'</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> <span class="c1">// No XSS filter</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You can utilize <code class="docutils literal"><span class="pre">method()</span></code> in order to know if you’re reading +PUT, DELETE or PATCH data.</p> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id7">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Input"> +<em class="property">class </em><code class="descname">CI_Input</code><a class="headerlink" href="#CI_Input" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$raw_input_stream</code></dt> +<dd><p>Read only property that will return php://input data as is.</p> +<p>The property can be read multiple times.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::post"> +<code class="descname">post</code><span class="sig-paren">(</span><span class="optional">[</span><em>$index = NULL</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::post" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>mixed</em>) – POST parameter name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">$_POST if no parameters supplied, otherwise the POST value if found or NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>The first parameter will contain the name of the POST item you are +looking for:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="s1">'some_data'</span><span class="p">);</span> +</pre></div> +</div> +<p>The method returns NULL if the item you are attempting to retrieve +does not exist.</p> +<p>The second optional parameter lets you run the data through the XSS +filter. It’s enabled by setting the second parameter to boolean TRUE +or by setting your <code class="docutils literal"><span class="pre">$config['global_xss_filtering']</span></code> to TRUE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="s1">'some_data'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +<p>To return an array of all POST items call without any parameters.</p> +<p>To return all POST items and pass them through the XSS filter set the +first parameter NULL while setting the second parameter to boolean TRUE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="k">NULL</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> <span class="c1">// returns all POST items with XSS filter</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="k">NULL</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> <span class="c1">// returns all POST items without XSS filter</span> +</pre></div> +</div> +<p>To return an array of multiple POST parameters, pass all the required keys +as an array.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">));</span> +</pre></div> +</div> +<p>Same rule applied here, to retrieve the parameters with XSS filtering enabled, set the +second parameter to boolean TRUE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">),</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::get"> +<code class="descname">get</code><span class="sig-paren">(</span><span class="optional">[</span><em>$index = NULL</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::get" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>mixed</em>) – GET parameter name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">$_GET if no parameters supplied, otherwise the GET value if found or NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">post()</span></code>, only it fetches GET data.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'some_data'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +<p>To return an array of all GET items call without any parameters.</p> +<p>To return all GET items and pass them through the XSS filter set the +first parameter NULL while setting the second parameter to boolean TRUE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="k">NULL</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> <span class="c1">// returns all GET items with XSS filter</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="k">NULL</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> <span class="c1">// returns all GET items without XSS filtering</span> +</pre></div> +</div> +<p>To return an array of multiple GET parameters, pass all the required keys +as an array.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">));</span> +</pre></div> +</div> +<p>Same rule applied here, to retrieve the parameters with XSS filtering enabled, set the +second parameter to boolean TRUE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">),</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::post_get"> +<code class="descname">post_get</code><span class="sig-paren">(</span><em>$index</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::post_get" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>string</em>) – POST/GET parameter name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">POST/GET value if found, NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method works pretty much the same way as <code class="docutils literal"><span class="pre">post()</span></code> and <code class="docutils literal"><span class="pre">get()</span></code>, +only combined. It will search through both POST and GET streams for data, +looking in POST first, and then in GET:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post_get</span><span class="p">(</span><span class="s1">'some_data'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::get_post"> +<code class="descname">get_post</code><span class="sig-paren">(</span><em>$index</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::get_post" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>string</em>) – GET/POST parameter name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">GET/POST value if found, NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method works the same way as <code class="docutils literal"><span class="pre">post_get()</span></code> only it looks for GET +data first.</p> +<blockquote> +<div>$this->input->get_post(‘some_data’, TRUE);</div></blockquote> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method used to act EXACTLY like <code class="docutils literal"><span class="pre">post_get()</span></code>, but it’s +behavior has changed in CodeIgniter 3.0.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::cookie"> +<code class="descname">cookie</code><span class="sig-paren">(</span><span class="optional">[</span><em>$index = NULL</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::cookie" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>mixed</em>) – COOKIE name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">$_COOKIE if no parameters supplied, otherwise the COOKIE value if found or NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">post()</span></code> and <code class="docutils literal"><span class="pre">get()</span></code>, only it fetches cookie +data:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">cookie</span><span class="p">(</span><span class="s1">'some_cookie'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">cookie</span><span class="p">(</span><span class="s1">'some_cookie'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> <span class="c1">// with XSS filter</span> +</pre></div> +</div> +<p>To return an array of multiple cookie values, pass all the required keys +as an array.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">cookie</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'some_cookie'</span><span class="p">,</span> <span class="s1">'some_cookie2'</span><span class="p">));</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Unlike the <a class="reference internal" href="../helpers/cookie_helper.html"><span class="doc">Cookie Helper</span></a> +function <a class="reference internal" href="../helpers/cookie_helper.html#get_cookie" title="get_cookie"><code class="xref php php-func docutils literal"><span class="pre">get_cookie()</span></code></a>, this method does NOT prepend +your configured <code class="docutils literal"><span class="pre">$config['cookie_prefix']</span></code> value.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::server"> +<code class="descname">server</code><span class="sig-paren">(</span><em>$index</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::server" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>mixed</em>) – Value name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">$_SERVER item value if found, NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to the <code class="docutils literal"><span class="pre">post()</span></code>, <code class="docutils literal"><span class="pre">get()</span></code> and <code class="docutils literal"><span class="pre">cookie()</span></code> +methods, only it fetches server data (<code class="docutils literal"><span class="pre">$_SERVER</span></code>):</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">server</span><span class="p">(</span><span class="s1">'some_data'</span><span class="p">);</span> +</pre></div> +</div> +<p>To return an array of multiple <code class="docutils literal"><span class="pre">$_SERVER</span></code> values, pass all the required keys +as an array.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">server</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'SERVER_PROTOCOL'</span><span class="p">,</span> <span class="s1">'REQUEST_URI'</span><span class="p">));</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::input_stream"> +<code class="descname">input_stream</code><span class="sig-paren">(</span><span class="optional">[</span><em>$index = NULL</em><span class="optional">[</span>, <em>$xss_clean = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::input_stream" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>mixed</em>) – Key name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Input stream array if no parameters supplied, otherwise the specified value if found or NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">get()</span></code>, <code class="docutils literal"><span class="pre">post()</span></code> and <code class="docutils literal"><span class="pre">cookie()</span></code>, +only it fetches the <em>php://input</em> stream data.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::set_cookie"> +<code class="descname">set_cookie</code><span class="sig-paren">(</span><em>$name = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$expire = ''</em><span class="optional">[</span>, <em>$domain = ''</em><span class="optional">[</span>, <em>$path = '/'</em><span class="optional">[</span>, <em>$prefix = ''</em><span class="optional">[</span>, <em>$secure = NULL</em><span class="optional">[</span>, <em>$httponly = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::set_cookie" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$name</strong> (<em>mixed</em>) – Cookie name or an array of parameters</li> +<li><strong>$value</strong> (<em>string</em>) – Cookie value</li> +<li><strong>$expire</strong> (<em>int</em>) – Cookie expiration time in seconds</li> +<li><strong>$domain</strong> (<em>string</em>) – Cookie domain</li> +<li><strong>$path</strong> (<em>string</em>) – Cookie path</li> +<li><strong>$prefix</strong> (<em>string</em>) – Cookie name prefix</li> +<li><strong>$secure</strong> (<em>bool</em>) – Whether to only transfer the cookie through HTTPS</li> +<li><strong>$httponly</strong> (<em>bool</em>) – Whether to only make the cookie accessible for HTTP requests (no JavaScript)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets a cookie containing the values you specify. There are two ways to +pass information to this method so that a cookie can be set: Array +Method, and Discrete Parameters:</p> +<p><strong>Array Method</strong></p> +<p>Using this method, an associative array is passed to the first +parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$cookie</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'The Cookie Name'</span><span class="p">,</span> + <span class="s1">'value'</span> <span class="o">=></span> <span class="s1">'The Value'</span><span class="p">,</span> + <span class="s1">'expire'</span> <span class="o">=></span> <span class="s1">'86500'</span><span class="p">,</span> + <span class="s1">'domain'</span> <span class="o">=></span> <span class="s1">'.some-domain.com'</span><span class="p">,</span> + <span class="s1">'path'</span> <span class="o">=></span> <span class="s1">'/'</span><span class="p">,</span> + <span class="s1">'prefix'</span> <span class="o">=></span> <span class="s1">'myprefix_'</span><span class="p">,</span> + <span class="s1">'secure'</span> <span class="o">=></span> <span class="k">TRUE</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">set_cookie</span><span class="p">(</span><span class="nv">$cookie</span><span class="p">);</span> +</pre></div> +</div> +<p><strong>Notes</strong></p> +<p>Only the name and value are required. To delete a cookie set it with the +expiration blank.</p> +<p>The expiration is set in <strong>seconds</strong>, which will be added to the current +time. Do not include the time, but rather only the number of seconds +from <em>now</em> that you wish the cookie to be valid. If the expiration is +set to zero the cookie will only last as long as the browser is open.</p> +<p>For site-wide cookies regardless of how your site is requested, add your +URL to the <strong>domain</strong> starting with a period, like this: +.your-domain.com</p> +<p>The path is usually not needed since the method sets a root path.</p> +<p>The prefix is only needed if you need to avoid name collisions with +other identically named cookies for your server.</p> +<p>The <em>httponly</em> and <em>secure</em> flags, when omitted, will default to your +<code class="docutils literal"><span class="pre">$config['cookie_httponly']</span></code> and <code class="docutils literal"><span class="pre">$config['cookie_secure']</span></code> settings.</p> +<p><strong>Discrete Parameters</strong></p> +<p>If you prefer, you can set the cookie by passing data using individual +parameters:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">set_cookie</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$value</span><span class="p">,</span> <span class="nv">$expire</span><span class="p">,</span> <span class="nv">$domain</span><span class="p">,</span> <span class="nv">$path</span><span class="p">,</span> <span class="nv">$prefix</span><span class="p">,</span> <span class="nv">$secure</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::ip_address"> +<code class="descname">ip_address</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::ip_address" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Visitor’s IP address or ‘0.0.0.0’ if not valid</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns the IP address for the current user. If the IP address is not +valid, the method will return ‘0.0.0.0’:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">ip_address</span><span class="p">();</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">This method takes into account the <code class="docutils literal"><span class="pre">$config['proxy_ips']</span></code> +setting and will return the reported HTTP_X_FORWARDED_FOR, +HTTP_CLIENT_IP, HTTP_X_CLIENT_IP or HTTP_X_CLUSTER_CLIENT_IP +address for the allowed IP addresses.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::valid_ip"> +<code class="descname">valid_ip</code><span class="sig-paren">(</span><em>$ip</em><span class="optional">[</span>, <em>$which = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::valid_ip" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$ip</strong> (<em>string</em>) – IP address</li> +<li><strong>$which</strong> (<em>string</em>) – IP protocol (‘ipv4’ or ‘ipv6’)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the address is valid, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Takes an IP address as input and returns TRUE or FALSE (boolean) depending +on whether it is valid or not.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The $this->input->ip_address() method above automatically +validates the IP address.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">valid_ip</span><span class="p">(</span><span class="nv">$ip</span><span class="p">))</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'Not Valid'</span><span class="p">;</span> +<span class="p">}</span> +<span class="k">else</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'Valid'</span><span class="p">;</span> +<span class="p">}</span> +</pre></div> +</div> +<p>Accepts an optional second string parameter of ‘ipv4’ or ‘ipv6’ to specify +an IP format. The default checks for both formats.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::user_agent"> +<code class="descname">user_agent</code><span class="sig-paren">(</span><span class="optional">[</span><em>$xss_clean = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::user_agent" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">User agent string or NULL if not set</p> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Returns the user agent string (web browser) being used by the current user, +or NULL if it’s not available.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">user_agent</span><span class="p">();</span> +</pre></div> +</div> +<p>See the <a class="reference internal" href="user_agent.html"><span class="doc">User Agent Class</span></a> for methods which extract +information from the user agent string.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::request_headers"> +<code class="descname">request_headers</code><span class="sig-paren">(</span><span class="optional">[</span><em>$xss_clean = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::request_headers" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An array of HTTP request headers</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns an array of HTTP request headers. +Useful if running in a non-Apache environment where +<a class="reference external" href="http://php.net/apache_request_headers">apache_request_headers()</a> +will not be supported.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$headers</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">request_headers</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::get_request_header"> +<code class="descname">get_request_header</code><span class="sig-paren">(</span><em>$index</em><span class="optional">[</span>, <em>$xss_clean = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::get_request_header" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$index</strong> (<em>string</em>) – HTTP request header name</li> +<li><strong>$xss_clean</strong> (<em>bool</em>) – Whether to apply XSS filtering</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTTP request header or NULL if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns a single member of the request headers array or NULL +if the searched header is not found.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">get_request_header</span><span class="p">(</span><span class="s1">'some-header'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::is_ajax_request"> +<code class="descname">is_ajax_request</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::is_ajax_request" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE if it is an Ajax request, FALSE if not</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>Checks to see if the HTTP_X_REQUESTED_WITH server header has been +set, and returns boolean TRUE if it is or FALSE if not.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::is_cli_request"> +<code class="descname">is_cli_request</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::is_cli_request" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE if it is a CLI request, FALSE if not</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>Checks to see if the application was run from the command-line +interface.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method checks both the PHP SAPI name currently in use +and if the <code class="docutils literal"><span class="pre">STDIN</span></code> constant is defined, which is usually a +failsafe way to see if PHP is being run via the command line.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">is_cli_request</span><span class="p">()</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is DEPRECATED and is now just an alias for the +<code class="xref py py-func docutils literal"><span class="pre">is_cli()</span></code> function.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Input::method"> +<code class="descname">method</code><span class="sig-paren">(</span><span class="optional">[</span><em>$upper = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Input::method" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$upper</strong> (<em>bool</em>) – Whether to return the request method name in upper or lower case</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTTP request method</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns the <code class="docutils literal"><span class="pre">$_SERVER['REQUEST_METHOD']</span></code>, with the option to set it +in uppercase or lowercase.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">method</span><span class="p">(</span><span class="k">TRUE</span><span class="p">);</span> <span class="c1">// Outputs: POST</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">method</span><span class="p">(</span><span class="k">FALSE</span><span class="p">);</span> <span class="c1">// Outputs: post</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">method</span><span class="p">();</span> <span class="c1">// Outputs: post</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="javascript.html" class="btn btn-neutral float-right" title="Javascript Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="image_lib.html" class="btn btn-neutral" title="Image Manipulation Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/javascript.html b/user_guide/libraries/javascript.html new file mode 100644 index 000000000..5a651db7d --- /dev/null +++ b/user_guide/libraries/javascript.html @@ -0,0 +1,802 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Javascript Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Language Class" href="language.html"/> + <link rel="prev" title="Input Class" href="input.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Javascript Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="javascript-class"> +<h1>Javascript Class<a class="headerlink" href="#javascript-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter provides a library to help you with certain common functions +that you may want to use with Javascript. Please note that CodeIgniter +does not require the jQuery library to run, and that any scripting +library will work equally well. The jQuery library is simply presented +as a convenience if you choose to use it.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">This library is DEPRECATED and should not be used. It has always +been with an ‘experimental’ status and is now no longer supported. +Currently only kept for backwards compatibility.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-javascript-class" id="id3">Using the Javascript Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id4">Initializing the Class</a></li> +<li><a class="reference internal" href="#setup-and-configuration" id="id5">Setup and Configuration</a><ul> +<li><a class="reference internal" href="#set-these-variables-in-your-view" id="id6">Set these variables in your view</a></li> +<li><a class="reference internal" href="#set-the-path-to-the-librarys-with-config-items" id="id7">Set the path to the librarys with config items</a></li> +</ul> +</li> +<li><a class="reference internal" href="#the-jquery-class" id="id8">The jQuery Class</a></li> +<li><a class="reference internal" href="#jquery-events" id="id9">jQuery Events</a></li> +<li><a class="reference internal" href="#effects" id="id10">Effects</a><ul> +<li><a class="reference internal" href="#hide-show" id="id11">hide() / show()</a></li> +<li><a class="reference internal" href="#toggle" id="id12">toggle()</a></li> +<li><a class="reference internal" href="#animate" id="id13">animate()</a></li> +<li><a class="reference internal" href="#fadein-fadeout" id="id14">fadeIn() / fadeOut()</a></li> +<li><a class="reference internal" href="#toggleclass" id="id15">toggleClass()</a></li> +<li><a class="reference internal" href="#id2" id="id16">fadeIn() / fadeOut()</a></li> +<li><a class="reference internal" href="#slideup-slidedown-slidetoggle" id="id17">slideUp() / slideDown() / slideToggle()</a></li> +</ul> +</li> +<li><a class="reference internal" href="#plugins" id="id18">Plugins</a><ul> +<li><a class="reference internal" href="#corner" id="id19">corner()</a></li> +<li><a class="reference internal" href="#tablesorter" id="id20">tablesorter()</a></li> +<li><a class="reference internal" href="#modal" id="id21">modal()</a></li> +<li><a class="reference internal" href="#calendar" id="id22">calendar()</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-javascript-class"> +<h2><a class="toc-backref" href="#id3">Using the Javascript Class</a><a class="headerlink" href="#using-the-javascript-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id4">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>To initialize the Javascript class manually in your controller +constructor, use the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method. Currently, +the only available library is jQuery, which will automatically be +loaded like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'javascript'</span><span class="p">);</span> +</pre></div> +</div> +<p>The Javascript class also accepts parameters:</p> +<ul class="simple"> +<li>js_library_driver (string) <em>default: ‘jquery’</em></li> +<li>autoload (bool) <em>default: TRUE</em></li> +</ul> +<p>You may override the defaults by sending an associative array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span> + <span class="s1">'javascript'</span><span class="p">,</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'js_library_driver'</span> <span class="o">=></span> <span class="s1">'scripto'</span><span class="p">,</span> + <span class="s1">'autoload'</span> <span class="o">=></span> <span class="k">FALSE</span> + <span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Again, presently only ‘jquery’ is available. You may wish to set +autoload to FALSE, though, if you do not want the jQuery library to +automatically include a script tag for the main jQuery script file. This +is useful if you are loading it from a location outside of CodeIgniter, +or already have the script tag in your markup.</p> +<p>Once loaded, the jQuery library object will be available using:</p> +<blockquote> +<div>$this->javascript</div></blockquote> +</div> +<div class="section" id="setup-and-configuration"> +<h3><a class="toc-backref" href="#id5">Setup and Configuration</a><a class="headerlink" href="#setup-and-configuration" title="Permalink to this headline">¶</a></h3> +<div class="section" id="set-these-variables-in-your-view"> +<h4><a class="toc-backref" href="#id6">Set these variables in your view</a><a class="headerlink" href="#set-these-variables-in-your-view" title="Permalink to this headline">¶</a></h4> +<p>As a Javascript library, your files must be available to your +application.</p> +<p>As Javascript is a client side language, the library must be able to +write content into your final output. This generally means a view. +You’ll need to include the following variables in the <code class="docutils literal"><span class="pre"><head></span></code> +sections of your output.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nv">$library_src</span><span class="p">;</span><span class="cp">?></span> +<span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$script_head</span><span class="p">;</span><span class="cp">?></span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">$library_src</span></code>, is where the actual library file will be loaded, as +well as any subsequent plugin script calls; $script_head is where +specific events, functions and other commands will be rendered.</p> +</div> +<div class="section" id="set-the-path-to-the-librarys-with-config-items"> +<h4><a class="toc-backref" href="#id7">Set the path to the librarys with config items</a><a class="headerlink" href="#set-the-path-to-the-librarys-with-config-items" title="Permalink to this headline">¶</a></h4> +<p>There are some configuration items in Javascript library. These can +either be set in <em>application/config.php</em>, within its own +<em>config/javascript.php</em> file, or within any controller usings the +<code class="docutils literal"><span class="pre">set_item()</span></code> function.</p> +<p>An image to be used as an “ajax loader”, or progress indicator. Without +one, the simple text message of “loading” will appear when Ajax calls +need to be made.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'javascript_location'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'http://localhost/codeigniter/themes/js/jquery/'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'javascript_ajax_img'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'images/ajax-loader.gif'</span><span class="p">;</span> +</pre></div> +</div> +<p>If you keep your files in the same directories they were downloaded +from, then you need not set this configuration items.</p> +</div> +</div> +<div class="section" id="the-jquery-class"> +<h3><a class="toc-backref" href="#id8">The jQuery Class</a><a class="headerlink" href="#the-jquery-class" title="Permalink to this headline">¶</a></h3> +<p>To initialize the jQuery class manually in your controller constructor, +use the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'javascript/jquery'</span><span class="p">);</span> +</pre></div> +</div> +<p>You may send an optional parameter to determine whether or not a script +tag for the main jQuery file will be automatically included when loading +the library. It will be created by default. To prevent this, load the +library as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'javascript/jquery'</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the jQuery library object will be available using:</p> +<blockquote> +<div>$this->jquery</div></blockquote> +</div> +<div class="section" id="jquery-events"> +<h3><a class="toc-backref" href="#id9">jQuery Events</a><a class="headerlink" href="#jquery-events" title="Permalink to this headline">¶</a></h3> +<p>Events are set using the following syntax.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">event</span><span class="p">(</span><span class="s1">'element_path'</span><span class="p">,</span> <span class="nx">code_to_run</span><span class="p">());</span> +</pre></div> +</div> +<p>In the above example:</p> +<ul class="simple"> +<li>“event” is any of blur, change, click, dblclick, error, focus, hover, +keydown, keyup, load, mousedown, mouseup, mouseover, mouseup, resize, +scroll, or unload.</li> +<li>“element_path” is any valid <a class="reference external" href="http://api.jquery.com/category/selectors/">jQuery selector</a>. Due to jQuery’s unique +selector syntax, this is usually an element id, or CSS selector. For +example “#notice_area” would effect <code class="docutils literal"><span class="pre"><div</span> <span class="pre">id="notice_area"></span></code>, and +“#content a.notice” would effect all anchors with a class of “notice” +in the div with id “content”.</li> +<li>“<code class="docutils literal"><span class="pre">code_to_run()</span></code>” is script your write yourself, or an action such as +an effect from the jQuery library below.</li> +</ul> +</div> +<div class="section" id="effects"> +<h3><a class="toc-backref" href="#id10">Effects</a><a class="headerlink" href="#effects" title="Permalink to this headline">¶</a></h3> +<p>The query library supports a powerful +<a class="reference external" href="http://api.jquery.com/category/effects/">Effects</a> repertoire. Before an effect +can be used, it must be loaded:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">effect</span><span class="p">([</span><span class="nx">optional</span> <span class="nx">path</span><span class="p">]</span> <span class="nx">plugin</span> <span class="nx">name</span><span class="p">);</span> <span class="c1">// for example $this->jquery->effect('bounce');</span> +</pre></div> +</div> +<div class="section" id="hide-show"> +<h4><a class="toc-backref" href="#id11">hide() / show()</a><a class="headerlink" href="#hide-show" title="Permalink to this headline">¶</a></h4> +<p>Each of this functions will affect the visibility of an item on your +page. hide() will set an item invisible, show() will reveal it.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">hide</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">show</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“speed” is optional, and is set to either slow, normal, fast, or +alternatively a number of milliseconds.</li> +<li>“extra information” is optional, and could include a callback, or +other additional information.</li> +</ul> +</div> +<div class="section" id="toggle"> +<h4><a class="toc-backref" href="#id12">toggle()</a><a class="headerlink" href="#toggle" title="Permalink to this headline">¶</a></h4> +<p>toggle() will change the visibility of an item to the opposite of its +current state, hiding visible elements, and revealing hidden ones.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">toggle</span><span class="p">(</span><span class="nx">target</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +</ul> +</div> +<div class="section" id="animate"> +<h4><a class="toc-backref" href="#id13">animate()</a><a class="headerlink" href="#animate" title="Permalink to this headline">¶</a></h4> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">animate</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">parameters</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“parameters” in jQuery would generally include a series of CSS +properties that you wish to change.</li> +<li>“speed” is optional, and is set to either slow, normal, fast, or +alternatively a number of milliseconds.</li> +<li>“extra information” is optional, and could include a callback, or +other additional information.</li> +</ul> +<p>For a full summary, see +<a class="reference external" href="http://api.jquery.com/animate/">http://api.jquery.com/animate/</a></p> +<p>Here is an example of an animate() called on a div with an id of “note”, +and triggered by a click using the jQuery library’s click() event.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$params</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> +<span class="s1">'height'</span> <span class="o">=></span> <span class="mi">80</span><span class="p">,</span> +<span class="s1">'width'</span> <span class="o">=></span> <span class="s1">'50%'</span><span class="p">,</span> +<span class="s1">'marginLeft'</span> <span class="o">=></span> <span class="mi">125</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">click</span><span class="p">(</span><span class="s1">'#trigger'</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">animate</span><span class="p">(</span><span class="s1">'#note'</span><span class="p">,</span> <span class="nv">$params</span><span class="p">,</span> <span class="s1">'normal'</span><span class="p">));</span> +</pre></div> +</div> +</div> +<div class="section" id="fadein-fadeout"> +<h4><a class="toc-backref" href="#id14">fadeIn() / fadeOut()</a><a class="headerlink" href="#fadein-fadeout" title="Permalink to this headline">¶</a></h4> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">fadeIn</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">fadeOut</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“speed” is optional, and is set to either slow, normal, fast, or +alternatively a number of milliseconds.</li> +<li>“extra information” is optional, and could include a callback, or +other additional information.</li> +</ul> +</div> +<div class="section" id="toggleclass"> +<h4><a class="toc-backref" href="#id15">toggleClass()</a><a class="headerlink" href="#toggleclass" title="Permalink to this headline">¶</a></h4> +<p>This function will add or remove a CSS class to its target.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">toggleClass</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">class</span><span class="p">)</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“class” is any CSS classname. Note that this class must be defined +and available in a CSS that is already loaded.</li> +</ul> +</div> +<div class="section" id="id2"> +<h4><a class="toc-backref" href="#id16">fadeIn() / fadeOut()</a><a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4> +<p>These effects cause an element(s) to disappear or reappear over time.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">fadeIn</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">fadeOut</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“speed” is optional, and is set to either slow, normal, fast, or +alternatively a number of milliseconds.</li> +<li>“extra information” is optional, and could include a callback, or +other additional information.</li> +</ul> +</div> +<div class="section" id="slideup-slidedown-slidetoggle"> +<h4><a class="toc-backref" href="#id17">slideUp() / slideDown() / slideToggle()</a><a class="headerlink" href="#slideup-slidedown-slidetoggle" title="Permalink to this headline">¶</a></h4> +<p>These effects cause an element(s) to slide.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">slideUp</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">slideDown</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">slideToggle</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">speed</span><span class="p">,</span> <span class="nx">optional</span> <span class="nx">extra</span> <span class="nx">information</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“speed” is optional, and is set to either slow, normal, fast, or +alternatively a number of milliseconds.</li> +<li>“extra information” is optional, and could include a callback, or +other additional information.</li> +</ul> +</div> +</div> +<div class="section" id="plugins"> +<h3><a class="toc-backref" href="#id18">Plugins</a><a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h3> +<p>Some select jQuery plugins are made available using this library.</p> +<div class="section" id="corner"> +<h4><a class="toc-backref" href="#id19">corner()</a><a class="headerlink" href="#corner" title="Permalink to this headline">¶</a></h4> +<p>Used to add distinct corners to page elements. For full details see +<a class="reference external" href="http://malsup.com/jquery/corner/">http://malsup.com/jquery/corner/</a></p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">corner</span><span class="p">(</span><span class="nx">target</span><span class="p">,</span> <span class="nx">corner_style</span><span class="p">);</span> +</pre></div> +</div> +<ul class="simple"> +<li>“target” will be any valid jQuery selector or selectors.</li> +<li>“corner_style” is optional, and can be set to any valid style such +as round, sharp, bevel, bite, dog, etc. Individual corners can be set +by following the style with a space and using “tl” (top left), “tr” +(top right), “bl” (bottom left), or “br” (bottom right).</li> +</ul> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">jquery</span><span class="o">-></span><span class="na">corner</span><span class="p">(</span><span class="s2">"#note"</span><span class="p">,</span> <span class="s2">"cool tl br"</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="tablesorter"> +<h4><a class="toc-backref" href="#id20">tablesorter()</a><a class="headerlink" href="#tablesorter" title="Permalink to this headline">¶</a></h4> +<p>description to come</p> +</div> +<div class="section" id="modal"> +<h4><a class="toc-backref" href="#id21">modal()</a><a class="headerlink" href="#modal" title="Permalink to this headline">¶</a></h4> +<p>description to come</p> +</div> +<div class="section" id="calendar"> +<h4><a class="toc-backref" href="#id22">calendar()</a><a class="headerlink" href="#calendar" title="Permalink to this headline">¶</a></h4> +<p>description to come</p> +</div> +</div> +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="language.html" class="btn btn-neutral float-right" title="Language Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="input.html" class="btn btn-neutral" title="Input Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html new file mode 100644 index 000000000..ba4c929ec --- /dev/null +++ b/user_guide/libraries/language.html @@ -0,0 +1,733 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Language Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Loader Class" href="loader.html"/> + <link rel="prev" title="Javascript Class" href="javascript.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Language Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="language-class"> +<h1>Language Class<a class="headerlink" href="#language-class" title="Permalink to this headline">¶</a></h1> +<p>The Language Class provides functions to retrieve language files and +lines of text for purposes of internationalization.</p> +<p>In your CodeIgniter <strong>system</strong> folder, you will find a <strong>language</strong> sub-directory +containing a set of language files for the <strong>english</strong> idiom. +The files in this directory (<strong>system/language/english/</strong>) define the regular messages, +error messages, and other generally output terms or expressions, for the different parts +of the CodeIgniter framework.</p> +<p>You can create or incorporate your own language files, as needed, in order to provide +application-specific error and other messages, or to provide translations of the core +messages into other languages. These translations or additional messages would go inside +your <strong>application/language/</strong> directory, with separate sub-directories for each idiom +(for instance, ‘french’ or ‘german’).</p> +<p>The CodeIgniter framework comes with a set of language files for the “english” idiom. +Additional approved translations for different idioms may be found in the +<a class="reference external" href="https://github.com/bcit-ci/codeigniter3-translations">CodeIgniter 3 Translations repositories</a>. +Each repository deals with a single idiom.</p> +<p>When CodeIgniter loads language files, it will load the one in <strong>system/language/</strong> +first and will then look for an override in your <strong>application/language/</strong> directory.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Each language should be stored in its own folder. For example, +the English files are located at: system/language/english</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#handling-multiple-languages" id="id1">Handling Multiple Languages</a><ul> +<li><a class="reference internal" href="#sample-language-files" id="id2">Sample Language Files</a></li> +<li><a class="reference internal" href="#example-of-switching-languages" id="id3">Example of switching languages</a></li> +</ul> +</li> +<li><a class="reference internal" href="#internationalization" id="id4">Internationalization</a></li> +<li><a class="reference internal" href="#using-the-language-class" id="id5">Using the Language Class</a><ul> +<li><a class="reference internal" href="#creating-language-files" id="id6">Creating Language Files</a></li> +<li><a class="reference internal" href="#loading-a-language-file" id="id7">Loading A Language File</a></li> +<li><a class="reference internal" href="#fetching-a-line-of-text" id="id8">Fetching a Line of Text</a><ul> +<li><a class="reference internal" href="#using-language-lines-as-form-labels" id="id9">Using language lines as form labels</a></li> +</ul> +</li> +<li><a class="reference internal" href="#auto-loading-languages" id="id10">Auto-loading Languages</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id11">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="handling-multiple-languages"> +<h2><a class="toc-backref" href="#id1">Handling Multiple Languages</a><a class="headerlink" href="#handling-multiple-languages" title="Permalink to this headline">¶</a></h2> +<p>If you want to support multiple languages in your application, you would provide folders inside +your <strong>application/language/</strong> directory for each of them, and you would specify the default +language in your <strong>application/config/config.php</strong>.</p> +<p>The <strong>application/language/english/</strong> directory would contain any additional language files +needed by your application, for instance for error messages.</p> +<p>Each of the other idiom-specific directories would contain the core language files that you +obtained from the translations repositories, or that you translated yourself, as well as +any additional ones needed by your application.</p> +<p>You would store the language you are currently using, for instance in a session variable.</p> +<div class="section" id="sample-language-files"> +<h3><a class="toc-backref" href="#id2">Sample Language Files</a><a class="headerlink" href="#sample-language-files" title="Permalink to this headline">¶</a></h3> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">system</span><span class="o">/</span> + <span class="nx">language</span><span class="o">/</span> + <span class="nx">english</span><span class="o">/</span> + <span class="o">...</span> + <span class="nx">email_lang</span><span class="o">.</span><span class="nx">php</span> + <span class="nx">form_validation_lang</span><span class="o">.</span><span class="nx">php</span> + <span class="o">...</span> + +<span class="nx">application</span><span class="o">/</span> + <span class="nx">language</span><span class="o">/</span> + <span class="nx">english</span><span class="o">/</span> + <span class="nx">error_messages_lang</span><span class="o">.</span><span class="nx">php</span> + <span class="nx">french</span><span class="o">/</span> + <span class="o">...</span> + <span class="nx">email_lang</span><span class="o">.</span><span class="nx">php</span> + <span class="nx">error_messages_lang</span><span class="o">.</span><span class="nx">php</span> + <span class="nx">form_validation_lang</span><span class="o">.</span><span class="nx">php</span> + <span class="o">...</span> +</pre></div> +</div> +</div> +<div class="section" id="example-of-switching-languages"> +<h3><a class="toc-backref" href="#id3">Example of switching languages</a><a class="headerlink" href="#example-of-switching-languages" title="Permalink to this headline">¶</a></h3> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$idiom</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">get_userdata</span><span class="p">(</span><span class="s1">'language'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'error_messages'</span><span class="p">,</span> <span class="nv">$idiom</span><span class="p">);</span> +<span class="nv">$oops</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">line</span><span class="p">(</span><span class="s1">'message_key'</span><span class="p">);</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="internationalization"> +<h2><a class="toc-backref" href="#id4">Internationalization</a><a class="headerlink" href="#internationalization" title="Permalink to this headline">¶</a></h2> +<p>The Language class in CodeIgniter is meant to provide an easy and lightweight +way to support multiplelanguages in your application. It is not meant to be a +full implementation of what is commonly called <a class="reference external" href="http://en.wikipedia.org/wiki/Internationalization_and_localization">internationalization and localization</a>.</p> +<p>We use the term “idiom” to refer to a language using its common name, +rather than using any of the international standards, such as “en”, “en-US”, +or “en-CA-x-ca” for English and some of its variants.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">There is nothing to prevent you from using those abbreviations in your application!</p> +</div> +</div> +<div class="section" id="using-the-language-class"> +<h2><a class="toc-backref" href="#id5">Using the Language Class</a><a class="headerlink" href="#using-the-language-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="creating-language-files"> +<h3><a class="toc-backref" href="#id6">Creating Language Files</a><a class="headerlink" href="#creating-language-files" title="Permalink to this headline">¶</a></h3> +<p>Language files must be named with <strong>_lang.php</strong> as the filename extension. +For example, let’s say you want to create a file containing error messages. +You might name it: error_lang.php</p> +<p>Within the file you will assign each line of text to an array called +<code class="docutils literal"><span class="pre">$lang</span></code> with this prototype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$lang</span><span class="p">[</span><span class="s1">'language_key'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'The actual message to be shown'</span><span class="p">;</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">It’s a good practice to use a common prefix for all messages +in a given file to avoid collisions with similarly named items in other +files. For example, if you are creating error messages you might prefix +them with error_</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$lang</span><span class="p">[</span><span class="s1">'error_email_missing'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'You must submit an email address'</span><span class="p">;</span> +<span class="nv">$lang</span><span class="p">[</span><span class="s1">'error_url_missing'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'You must submit a URL'</span><span class="p">;</span> +<span class="nv">$lang</span><span class="p">[</span><span class="s1">'error_username_missing'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'You must submit a username'</span><span class="p">;</span> +</pre></div> +</div> +</div> +<div class="section" id="loading-a-language-file"> +<h3><a class="toc-backref" href="#id7">Loading A Language File</a><a class="headerlink" href="#loading-a-language-file" title="Permalink to this headline">¶</a></h3> +<p>In order to fetch a line from a particular file you must load the file +first. Loading a language file is done with the following code:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="s1">'filename'</span><span class="p">,</span> <span class="s1">'language'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where filename is the name of the file you wish to load (without the +file extension), and language is the language set containing it (ie, +english). If the second parameter is missing, the default language set +in your <strong>application/config/config.php</strong> file will be used.</p> +<p>You can also load multiple language files at the same time by passing an array of language files as first parameter.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">load</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'filename1'</span><span class="p">,</span> <span class="s1">'filename2'</span><span class="p">));</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The <em>language</em> parameter can only consist of letters.</p> +</div> +</div> +<div class="section" id="fetching-a-line-of-text"> +<h3><a class="toc-backref" href="#id8">Fetching a Line of Text</a><a class="headerlink" href="#fetching-a-line-of-text" title="Permalink to this headline">¶</a></h3> +<p>Once your desired language file is loaded you can access any line of +text using this function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">line</span><span class="p">(</span><span class="s1">'language_key'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where <em>language_key</em> is the array key corresponding to the line you wish +to show.</p> +<p>You can optionally pass FALSE as the second argument of that method to +disable error logging, in case you’re not sure if the line exists:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">lang</span><span class="o">-></span><span class="na">line</span><span class="p">(</span><span class="s1">'misc_key'</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method simply returns the line. It does not echo it.</p> +</div> +<div class="section" id="using-language-lines-as-form-labels"> +<h4><a class="toc-backref" href="#id9">Using language lines as form labels</a><a class="headerlink" href="#using-language-lines-as-form-labels" title="Permalink to this headline">¶</a></h4> +<p>This feature has been deprecated from the language library and moved to +the <a class="reference internal" href="../helpers/language_helper.html#lang" title="lang"><code class="xref php php-func docutils literal"><span class="pre">lang()</span></code></a> function of the <a class="reference internal" href="../helpers/language_helper.html"><span class="doc">Language Helper</span></a>.</p> +</div> +</div> +<div class="section" id="auto-loading-languages"> +<h3><a class="toc-backref" href="#id10">Auto-loading Languages</a><a class="headerlink" href="#auto-loading-languages" title="Permalink to this headline">¶</a></h3> +<p>If you find that you need a particular language globally throughout your +application, you can tell CodeIgniter to <a class="reference internal" href="../general/autoloader.html"><span class="doc">auto-load</span></a> it during system initialization. This is done +by opening the <strong>application/config/autoload.php</strong> file and adding the +language(s) to the autoload array.</p> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id11">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Lang"> +<em class="property">class </em><code class="descname">CI_Lang</code><a class="headerlink" href="#CI_Lang" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Lang::load"> +<code class="descname">load</code><span class="sig-paren">(</span><em>$langfile</em><span class="optional">[</span>, <em>$idiom = ''</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">[</span>, <em>$add_suffix = TRUE</em><span class="optional">[</span>, <em>$alt_path = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Lang::load" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$langfile</strong> (<em>mixed</em>) – Language file to load or array with multiple files</li> +<li><strong>$idiom</strong> (<em>string</em>) – Language name (i.e. ‘english’)</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to return the loaded array of translations</li> +<li><strong>$add_suffix</strong> (<em>bool</em>) – Whether to add the ‘_lang’ suffix to the language file name</li> +<li><strong>$alt_path</strong> (<em>string</em>) – An alternative path to look in for the language file</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of language lines if $return is set to TRUE, otherwise void</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Loads a language file.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Lang::line"> +<code class="descname">line</code><span class="sig-paren">(</span><em>$line</em><span class="optional">[</span>, <em>$log_errors = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Lang::line" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$line</strong> (<em>string</em>) – Language line key name</li> +<li><strong>$log_errors</strong> (<em>bool</em>) – Whether to log an error if the line isn’t found</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Language line string or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Fetches a single translation line from the already loaded language files, +based on the line’s name.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="loader.html" class="btn btn-neutral float-right" title="Loader Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="javascript.html" class="btn btn-neutral" title="Javascript Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html new file mode 100644 index 000000000..46360b5e8 --- /dev/null +++ b/user_guide/libraries/loader.html @@ -0,0 +1,1213 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Loader Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Migrations Class" href="migration.html"/> + <link rel="prev" title="Language Class" href="language.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Loader Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="loader-class"> +<h1>Loader Class<a class="headerlink" href="#loader-class" title="Permalink to this headline">¶</a></h1> +<p>Loader, as the name suggests, is used to load elements. These elements +can be libraries (classes) <a class="reference internal" href="../general/views.html"><span class="doc">View files</span></a>, +<a class="reference internal" href="../general/drivers.html"><span class="doc">Drivers</span></a>, +<a class="reference internal" href="../general/helpers.html"><span class="doc">Helpers</span></a>, +<a class="reference internal" href="../general/models.html"><span class="doc">Models</span></a>, or your own files.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This class is initialized automatically by the system so there +is no need to do it manually.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#application-packages" id="id2">Application “Packages”</a><ul> +<li><a class="reference internal" href="#package-view-files" id="id3">Package view files</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id4">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="application-packages"> +<h2><a class="toc-backref" href="#id2">Application “Packages”</a><a class="headerlink" href="#application-packages" title="Permalink to this headline">¶</a></h2> +<p>An application package allows for the easy distribution of complete sets +of resources in a single directory, complete with its own libraries, +models, helpers, config, and language files. It is recommended that +these packages be placed in the application/third_party directory. Below +is a sample map of an package directory.</p> +<p>The following is an example of a directory for an application package +named “Foo Bar”.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">/</span><span class="nx">application</span><span class="o">/</span><span class="nx">third_party</span><span class="o">/</span><span class="nx">foo_bar</span> + +<span class="nx">config</span><span class="o">/</span> +<span class="nx">helpers</span><span class="o">/</span> +<span class="nx">language</span><span class="o">/</span> +<span class="nx">libraries</span><span class="o">/</span> +<span class="nx">models</span><span class="o">/</span> +</pre></div> +</div> +<p>Whatever the purpose of the “Foo Bar” application package, it has its +own config files, helpers, language files, libraries, and models. To use +these resources in your controllers, you first need to tell the Loader +that you are going to be loading resources from a package, by adding the +package path via the <code class="docutils literal"><span class="pre">add_package_path()</span></code> method.</p> +<div class="section" id="package-view-files"> +<h3><a class="toc-backref" href="#id3">Package view files</a><a class="headerlink" href="#package-view-files" title="Permalink to this headline">¶</a></h3> +<p>By Default, package view files paths are set when <code class="docutils literal"><span class="pre">add_package_path()</span></code> +is called. View paths are looped through, and once a match is +encountered that view is loaded.</p> +<p>In this instance, it is possible for view naming collisions within +packages to occur, and possibly the incorrect package being loaded. To +ensure against this, set an optional second parameter of FALSE when +calling <code class="docutils literal"><span class="pre">add_package_path()</span></code>.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">add_package_path</span><span class="p">(</span><span class="nx">APPPATH</span><span class="o">.</span><span class="s1">'my_app'</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'my_app_index'</span><span class="p">);</span> <span class="c1">// Loads</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'welcome_message'</span><span class="p">);</span> <span class="c1">// Will not load the default welcome_message b/c the second param to add_package_path is FALSE</span> + +<span class="c1">// Reset things</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">remove_package_path</span><span class="p">(</span><span class="nx">APPPATH</span><span class="o">.</span><span class="s1">'my_app'</span><span class="p">);</span> + +<span class="c1">// Again without the second parameter:</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">add_package_path</span><span class="p">(</span><span class="nx">APPPATH</span><span class="o">.</span><span class="s1">'my_app'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'my_app_index'</span><span class="p">);</span> <span class="c1">// Loads</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'welcome_message'</span><span class="p">);</span> <span class="c1">// Loads</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id4">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Loader"> +<em class="property">class </em><code class="descname">CI_Loader</code><a class="headerlink" href="#CI_Loader" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Loader::library"> +<code class="descname">library</code><span class="sig-paren">(</span><em>$library</em><span class="optional">[</span>, <em>$params = NULL</em><span class="optional">[</span>, <em>$object_name = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::library" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$library</strong> (<em>mixed</em>) – Library name as a string or an array with multiple libraries</li> +<li><strong>$params</strong> (<em>array</em>) – Optional array of parameters to pass to the loaded library’s constructor</li> +<li><strong>$object_name</strong> (<em>string</em>) – Optional object name to assign the library to</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>This method is used to load core classes.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">We use the terms “class” and “library” interchangeably.</p> +</div> +<p>For example, if you would like to send email with CodeIgniter, the first +step is to load the email class within your controller:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'email'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the library will be ready for use, using <code class="docutils literal"><span class="pre">$this->email</span></code>.</p> +<p>Library files can be stored in subdirectories within the main +“libraries” directory, or within your personal <em>application/libraries</em> +directory. To load a file located in a subdirectory, simply include the +path, relative to the “libraries” directory. For example, if you have +file located at:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">libraries</span><span class="o">/</span><span class="nx">flavors</span><span class="o">/</span><span class="nx">Chocolate</span><span class="o">.</span><span class="nx">php</span> +</pre></div> +</div> +<p>You will load it using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'flavors/chocolate'</span><span class="p">);</span> +</pre></div> +</div> +<p>You may nest the file in as many subdirectories as you want.</p> +<p>Additionally, multiple libraries can be loaded at the same time by +passing an array of libraries to the load method.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="s1">'table'</span><span class="p">));</span> +</pre></div> +</div> +<p><strong>Setting options</strong></p> +<p>The second (optional) parameter allows you to optionally pass +configuration setting. You will typically pass these as an array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> + <span class="s1">'mailtype'</span> <span class="o">=></span> <span class="s1">'html'</span><span class="p">,</span> + <span class="s1">'charset'</span> <span class="o">=></span> <span class="s1">'utf-8'</span><span class="p">,</span> + <span class="s1">'priority'</span> <span class="o">=></span> <span class="s1">'1'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'email'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">);</span> +</pre></div> +</div> +<p>Config options can usually also be set via a config file. Each library +is explained in detail in its own page, so please read the information +regarding each one you would like to use.</p> +<p>Please take note, when multiple libraries are supplied in an array for +the first parameter, each will receive the same parameter information.</p> +<p><strong>Assigning a Library to a different object name</strong></p> +<p>If the third (optional) parameter is blank, the library will usually be +assigned to an object with the same name as the library. For example, if +the library is named Calendar, it will be assigned to a variable named +<code class="docutils literal"><span class="pre">$this->calendar</span></code>.</p> +<p>If you prefer to set your own class names you can pass its value to the +third parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'calendar'</span><span class="p">,</span> <span class="k">NULL</span><span class="p">,</span> <span class="s1">'my_calendar'</span><span class="p">);</span> + +<span class="c1">// Calendar class is now accessed using:</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">my_calendar</span> +</pre></div> +</div> +<p>Please take note, when multiple libraries are supplied in an array for +the first parameter, this parameter is discarded.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::driver"> +<code class="descname">driver</code><span class="sig-paren">(</span><em>$library</em><span class="optional">[</span>, <em>$params = NULL</em><span class="optional">[</span>, <em>$object_name</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::driver" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$library</strong> (<em>mixed</em>) – Library name as a string or an array with multiple libraries</li> +<li><strong>$params</strong> (<em>array</em>) – Optional array of parameters to pass to the loaded library’s constructor</li> +<li><strong>$object_name</strong> (<em>string</em>) – Optional object name to assign the library to</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>This method is used to load driver libraries, acts very much like the +<code class="docutils literal"><span class="pre">library()</span></code> method.</p> +<p>As an example, if you would like to use sessions with CodeIgniter, the first +step is to load the session driver within your controller:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'session'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the library will be ready for use, using <code class="docutils literal"><span class="pre">$this->session</span></code>.</p> +<p>Driver files must be stored in a subdirectory within the main +“libraries” directory, or within your personal <em>application/libraries</em> +directory. The subdirectory must match the parent class name. Read the +<a class="reference internal" href="../general/drivers.html"><span class="doc">Drivers</span></a> description for details.</p> +<p>Additionally, multiple driver libraries can be loaded at the same time by +passing an array of drivers to the load method.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'session'</span><span class="p">,</span> <span class="s1">'cache'</span><span class="p">));</span> +</pre></div> +</div> +<p><strong>Setting options</strong></p> +<p>The second (optional) parameter allows you to optionally pass +configuration settings. You will typically pass these as an array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'sess_driver'</span> <span class="o">=></span> <span class="s1">'cookie'</span><span class="p">,</span> + <span class="s1">'sess_encrypt_cookie'</span> <span class="o">=></span> <span class="k">true</span><span class="p">,</span> + <span class="s1">'encryption_key'</span> <span class="o">=></span> <span class="s1">'mysecretkey'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">driver</span><span class="p">(</span><span class="s1">'session'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">);</span> +</pre></div> +</div> +<p>Config options can usually also be set via a config file. Each library +is explained in detail in its own page, so please read the information +regarding each one you would like to use.</p> +<p><strong>Assigning a Driver to a different object name</strong></p> +<p>If the third (optional) parameter is blank, the library will be assigned +to an object with the same name as the parent class. For example, if +the library is named Session, it will be assigned to a variable named +<code class="docutils literal"><span class="pre">$this->session</span></code>.</p> +<p>If you prefer to set your own class names you can pass its value to the +third parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'session'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="s1">'my_session'</span><span class="p">);</span> + +<span class="c1">// Session class is now accessed using:</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">my_session</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::view"> +<code class="descname">view</code><span class="sig-paren">(</span><em>$view</em><span class="optional">[</span>, <em>$vars = array()</em><span class="optional">[</span>, <em>return = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::view" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$view</strong> (<em>string</em>) – View name</li> +<li><strong>$vars</strong> (<em>array</em>) – An associative array of variables</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to return the loaded view</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">View content string if $return is set to TRUE, otherwise CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is used to load your View files. If you haven’t read the +<a class="reference internal" href="../general/views.html"><span class="doc">Views</span></a> section of the user guide it is +recommended that you do since it shows you how this method is +typically used.</p> +<p>The first parameter is required. It is the name of the view file you +would like to load.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The .php file extension does not need to be specified unless +you use something other than .php.</p> +</div> +<p>The second <strong>optional</strong> parameter can take an associative array or an +object as input, which it runs through the PHP +<a class="reference external" href="http://php.net/extract">extract()</a> function to convert to variables +that can be used in your view files. Again, read the +<a class="reference internal" href="../general/views.html"><span class="doc">Views</span></a> page to learn how this might be useful.</p> +<p>The third <strong>optional</strong> parameter lets you change the behavior of the +method so that it returns data as a string rather than sending it to +your browser. This can be useful if you want to process the data in some +way. If you set the parameter to TRUE (boolean) it will return data. The +default behavior is FALSE, which sends it to your browser. Remember to +assign it to a variable if you want the data returned:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'myfile'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::vars"> +<code class="descname">vars</code><span class="sig-paren">(</span><em>$vars</em><span class="optional">[</span>, <em>$val = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::vars" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$vars</strong> (<em>mixed</em>) – An array of variables or a single variable name</li> +<li><strong>$val</strong> (<em>mixed</em>) – Optional variable value</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>This method takes an associative array as input and generates +variables using the PHP <a class="reference external" href="http://php.net/extract">extract()</a> +function. This method produces the same result as using the second +parameter of the <code class="docutils literal"><span class="pre">$this->load->view()</span></code> method above. The reason you +might want to use this method independently is if you would like to +set some global variables in the constructor of your controller and have +them become available in any view file loaded from any method. You can +have multiple calls to this method. The data get cached and merged +into one array for conversion to variables.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::get_var"> +<code class="descname">get_var</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::get_var" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Variable name key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value if key is found, NULL if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method checks the associative array of variables available to +your views. This is useful if for any reason a var is set in a library +or another controller method using <code class="docutils literal"><span class="pre">$this->load->vars()</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::get_vars"> +<code class="descname">get_vars</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::get_vars" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array of all assigned view variables</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>This method retrieves all variables available to your views.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::clear_vars"> +<code class="descname">clear_vars</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::clear_vars" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">CI_Loader instance (method chaining)</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">CI_Loader</td> +</tr> +</tbody> +</table> +<p>Clears cached view variables.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::model"> +<code class="descname">model</code><span class="sig-paren">(</span><em>$model</em><span class="optional">[</span>, <em>$name = ''</em><span class="optional">[</span>, <em>$db_conn = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::model" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$model</strong> (<em>mixed</em>) – Model name or an array containing multiple models</li> +<li><strong>$name</strong> (<em>string</em>) – Optional object name to assign the model to</li> +<li><strong>$db_conn</strong> (<em>string</em>) – Optional database configuration group to load</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">model</span><span class="p">(</span><span class="s1">'model_name'</span><span class="p">);</span> +</pre></div> +</div> +<p>If your model is located in a subdirectory, include the relative path +from your models directory. For example, if you have a model located at +<em>application/models/blog/Queries.php</em> you’ll load it using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">model</span><span class="p">(</span><span class="s1">'blog/queries'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you would like your model assigned to a different object name you can +specify it via the second parameter of the loading method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">model</span><span class="p">(</span><span class="s1">'model_name'</span><span class="p">,</span> <span class="s1">'fubar'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">fubar</span><span class="o">-></span><span class="na">method</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::database"> +<code class="descname">database</code><span class="sig-paren">(</span><span class="optional">[</span><em>$params = ''</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">[</span>, <em>$query_builder = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::database" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$params</strong> (<em>mixed</em>) – Database group name or configuration options</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to return the loaded database object</li> +<li><strong>$query_builder</strong> (<em>bool</em>) – Whether to load the Query Builder</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Loaded CI_DB instance or FALSE on failure if $return is set to TRUE, otherwise CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method lets you load the database class. The two parameters are +<strong>optional</strong>. Please see the <a class="reference internal" href="../database/index.html"><span class="doc">database</span></a> +section for more info.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::dbforge"> +<code class="descname">dbforge</code><span class="sig-paren">(</span><span class="optional">[</span><em>$db = NULL</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::dbforge" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$db</strong> (<em>object</em>) – Database object</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to return the Database Forge instance</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Loaded CI_DB_forge instance if $return is set to TRUE, otherwise CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Loads the <a class="reference internal" href="../database/forge.html"><span class="doc">Database Forge</span></a> class, please refer +to that manual for more info.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::dbutil"> +<code class="descname">dbutil</code><span class="sig-paren">(</span><span class="optional">[</span><em>$db = NULL</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::dbutil" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$db</strong> (<em>object</em>) – Database object</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to return the Database Utilities instance</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Loaded CI_DB_utility instance if $return is set to TRUE, otherwise CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Loads the <a class="reference internal" href="../database/utilities.html"><span class="doc">Database Utilities</span></a> class, please +refer to that manual for more info.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::helper"> +<code class="descname">helper</code><span class="sig-paren">(</span><em>$helpers</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::helper" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$helpers</strong> (<em>mixed</em>) – Helper name as a string or an array containing multiple helpers</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>This method loads helper files, where file_name is the name of the +file, without the _helper.php extension.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::file"> +<code class="descname">file</code><span class="sig-paren">(</span><em>$path</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::file" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – File path</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to return the loaded file</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">File contents if $return is set to TRUE, otherwise CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This is a generic file loading method. Supply the filepath and name in +the first parameter and it will open and read the file. By default the +data is sent to your browser, just like a View file, but if you set the +second parameter to boolean TRUE it will instead return the data as a +string.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::language"> +<code class="descname">language</code><span class="sig-paren">(</span><em>$files</em><span class="optional">[</span>, <em>$lang = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::language" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$files</strong> (<em>mixed</em>) – Language file name or an array of multiple language files</li> +<li><strong>$lang</strong> (<em>string</em>) – Language name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>This method is an alias of the <a class="reference internal" href="language.html"><span class="doc">language loading +method</span></a>: <code class="docutils literal"><span class="pre">$this->lang->load()</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::config"> +<code class="descname">config</code><span class="sig-paren">(</span><em>$file</em><span class="optional">[</span>, <em>$use_sections = FALSE</em><span class="optional">[</span>, <em>$fail_gracefully = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::config" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$file</strong> (<em>string</em>) – Configuration file name</li> +<li><strong>$use_sections</strong> (<em>bool</em>) – Whether configuration values should be loaded into their own section</li> +<li><strong>$fail_gracefully</strong> (<em>bool</em>) – Whether to just return FALSE in case of failure</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>This method is an alias of the <a class="reference internal" href="config.html"><span class="doc">config file loading +method</span></a>: <code class="docutils literal"><span class="pre">$this->config->load()</span></code></p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::is_loaded"> +<code class="descname">is_loaded</code><span class="sig-paren">(</span><em>$class</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::is_loaded" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$class</strong> (<em>string</em>) – Class name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Singleton property name if found, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Allows you to check if a class has already been loaded or not.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The word “class” here refers to libraries and drivers.</p> +</div> +<p>If the requested class has been loaded, the method returns its assigned +name in the CI Super-object and FALSE if it’s not:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">is_loaded</span><span class="p">(</span><span class="s1">'Form_validation'</span><span class="p">);</span> <span class="c1">// returns 'form_validation'</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">is_loaded</span><span class="p">(</span><span class="s1">'Nonexistent_library'</span><span class="p">);</span> <span class="c1">// returns FALSE</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">If you have more than one instance of a class (assigned to +different properties), then the first one will be returned.</p> +</div> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">,</span> <span class="s1">'fv'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'form_validation'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">is_loaded</span><span class="p">(</span><span class="s1">'Form_validation'</span><span class="p">);</span> <span class="c1">// returns 'fv'</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::add_package_path"> +<code class="descname">add_package_path</code><span class="sig-paren">(</span><em>$path</em><span class="optional">[</span>, <em>$view_cascade = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::add_package_path" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Path to add</li> +<li><strong>$view_cascade</strong> (<em>bool</em>) – Whether to use cascading views</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>Adding a package path instructs the Loader class to prepend a given path +for subsequent requests for resources. As an example, the “Foo Bar” +application package above has a library named Foo_bar.php. In our +controller, we’d do the following:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">add_package_path</span><span class="p">(</span><span class="nx">APPPATH</span><span class="o">.</span><span class="s1">'third_party/foo_bar/'</span><span class="p">)</span> + <span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'foo_bar'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::remove_package_path"> +<code class="descname">remove_package_path</code><span class="sig-paren">(</span><span class="optional">[</span><em>$path = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::remove_package_path" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Path to remove</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Loader instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Loader</p> +</td> +</tr> +</tbody> +</table> +<p>When your controller is finished using resources from an application +package, and particularly if you have other application packages you +want to work with, you may wish to remove the package path so the Loader +no longer looks in that directory for resources. To remove the last path +added, simply call the method with no parameters.</p> +<p>Or to remove a specific package path, specify the same path previously +given to <code class="docutils literal"><span class="pre">add_package_path()</span></code> for a package.:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">remove_package_path</span><span class="p">(</span><span class="nx">APPPATH</span><span class="o">.</span><span class="s1">'third_party/foo_bar/'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Loader::get_package_paths"> +<code class="descname">get_package_paths</code><span class="sig-paren">(</span><span class="optional">[</span><em>$include_base = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Loader::get_package_paths" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$include_base</strong> (<em>bool</em>) – Whether to include BASEPATH</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An array of package paths</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns all currently available package paths.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="migration.html" class="btn btn-neutral float-right" title="Migrations Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="language.html" class="btn btn-neutral" title="Language Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/migration.html b/user_guide/libraries/migration.html new file mode 100644 index 000000000..ec52ec52b --- /dev/null +++ b/user_guide/libraries/migration.html @@ -0,0 +1,758 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Migrations Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Output Class" href="output.html"/> + <link rel="prev" title="Loader Class" href="loader.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Migrations Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="migrations-class"> +<h1>Migrations Class<a class="headerlink" href="#migrations-class" title="Permalink to this headline">¶</a></h1> +<p>Migrations are a convenient way for you to alter your database in a +structured and organized manner. You could edit fragments of SQL by hand +but you would then be responsible for telling other developers that they +need to go and run them. You would also have to keep track of which changes +need to be run against the production machines next time you deploy.</p> +<p>The database table <strong>migration</strong> tracks which migrations have already been +run so all you have to do is update your application files and +call <code class="docutils literal"><span class="pre">$this->migration->current()</span></code> to work out which migrations should be run. +The current version is found in <strong>application/config/migration.php</strong>.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#migration-file-names" id="id1">Migration file names</a></li> +<li><a class="reference internal" href="#create-a-migration" id="id2">Create a Migration</a></li> +<li><a class="reference internal" href="#usage-example" id="id3">Usage Example</a></li> +<li><a class="reference internal" href="#migration-preferences" id="id4">Migration Preferences</a></li> +<li><a class="reference internal" href="#class-reference" id="id5">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="migration-file-names"> +<h2><a class="toc-backref" href="#id1">Migration file names</a><a class="headerlink" href="#migration-file-names" title="Permalink to this headline">¶</a></h2> +<p>Each Migration is run in numeric order forward or backwards depending on the +method taken. Two numbering styles are available:</p> +<ul class="simple"> +<li><strong>Sequential:</strong> each migration is numbered in sequence, starting with <strong>001</strong>. +Each number must be three digits, and there must not be any gaps in the +sequence. (This was the numbering scheme prior to CodeIgniter 3.0.)</li> +<li><strong>Timestamp:</strong> each migration is numbered using the timestamp when the migration +was created, in <strong>YYYYMMDDHHIISS</strong> format (e.g. <strong>20121031100537</strong>). This +helps prevent numbering conflicts when working in a team environment, and is +the preferred scheme in CodeIgniter 3.0 and later.</li> +</ul> +<p>The desired style may be selected using the <code class="docutils literal"><span class="pre">$config['migration_type']</span></code> +setting in your <em>application/config/migration.php</em> file.</p> +<p>Regardless of which numbering style you choose to use, prefix your migration +files with the migration number followed by an underscore and a descriptive +name for the migration. For example:</p> +<ul class="simple"> +<li>001_add_blog.php (sequential numbering)</li> +<li>20121031100537_add_blog.php (timestamp numbering)</li> +</ul> +</div> +<div class="section" id="create-a-migration"> +<h2><a class="toc-backref" href="#id2">Create a Migration</a><a class="headerlink" href="#create-a-migration" title="Permalink to this headline">¶</a></h2> +<p>This will be the first migration for a new site which has a blog. All +migrations go in the <strong>application/migrations/</strong> directory and have names such +as <em>20121031100537_add_blog.php</em>.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="nb">defined</span><span class="p">(</span><span class="s1">'BASEPATH'</span><span class="p">)</span> <span class="k">OR</span> <span class="k">exit</span><span class="p">(</span><span class="s1">'No direct script access allowed'</span><span class="p">);</span> + +<span class="k">class</span> <span class="nc">Migration_Add_blog</span> <span class="k">extends</span> <span class="nx">CI_Migration</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">up</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">dbforge</span><span class="o">-></span><span class="na">add_field</span><span class="p">(</span><span class="k">array</span><span class="p">(</span> + <span class="s1">'blog_id'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'type'</span> <span class="o">=></span> <span class="s1">'INT'</span><span class="p">,</span> + <span class="s1">'constraint'</span> <span class="o">=></span> <span class="mi">5</span><span class="p">,</span> + <span class="s1">'unsigned'</span> <span class="o">=></span> <span class="k">TRUE</span><span class="p">,</span> + <span class="s1">'auto_increment'</span> <span class="o">=></span> <span class="k">TRUE</span> + <span class="p">),</span> + <span class="s1">'blog_title'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'type'</span> <span class="o">=></span> <span class="s1">'VARCHAR'</span><span class="p">,</span> + <span class="s1">'constraint'</span> <span class="o">=></span> <span class="s1">'100'</span><span class="p">,</span> + <span class="p">),</span> + <span class="s1">'blog_description'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'type'</span> <span class="o">=></span> <span class="s1">'TEXT'</span><span class="p">,</span> + <span class="s1">'null'</span> <span class="o">=></span> <span class="k">TRUE</span><span class="p">,</span> + <span class="p">),</span> + <span class="p">));</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">dbforge</span><span class="o">-></span><span class="na">add_key</span><span class="p">(</span><span class="s1">'blog_id'</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">dbforge</span><span class="o">-></span><span class="na">create_table</span><span class="p">(</span><span class="s1">'blog'</span><span class="p">);</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">down</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">dbforge</span><span class="o">-></span><span class="na">drop_table</span><span class="p">(</span><span class="s1">'blog'</span><span class="p">);</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +<p>Then in <strong>application/config/migration.php</strong> set <code class="docutils literal"><span class="pre">$config['migration_version']</span> <span class="pre">=</span> <span class="pre">20121031100537;</span></code>.</p> +</div> +<div class="section" id="usage-example"> +<h2><a class="toc-backref" href="#id3">Usage Example</a><a class="headerlink" href="#usage-example" title="Permalink to this headline">¶</a></h2> +<p>In this example some simple code is placed in <strong>application/controllers/Migrate.php</strong> +to update the schema.:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Migrate</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> +<span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'migration'</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">migration</span><span class="o">-></span><span class="na">current</span><span class="p">()</span> <span class="o">===</span> <span class="k">FALSE</span><span class="p">)</span> + <span class="p">{</span> + <span class="nx">show_error</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">migration</span><span class="o">-></span><span class="na">error_string</span><span class="p">());</span> + <span class="p">}</span> + <span class="p">}</span> + +<span class="p">}</span> +</pre></div> +</div> +</div> +<div class="section" id="migration-preferences"> +<h2><a class="toc-backref" href="#id4">Migration Preferences</a><a class="headerlink" href="#migration-preferences" title="Permalink to this headline">¶</a></h2> +<p>The following is a table of all the config options for migrations.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="22%" /> +<col width="18%" /> +<col width="22%" /> +<col width="38%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>migration_enabled</strong></td> +<td>FALSE</td> +<td>TRUE / FALSE</td> +<td>Enable or disable migrations.</td> +</tr> +<tr class="row-odd"><td><strong>migration_path</strong></td> +<td>APPPATH.’migrations/’</td> +<td>None</td> +<td>The path to your migrations folder.</td> +</tr> +<tr class="row-even"><td><strong>migration_version</strong></td> +<td>0</td> +<td>None</td> +<td>The current version your database should use.</td> +</tr> +<tr class="row-odd"><td><strong>migration_table</strong></td> +<td>migrations</td> +<td>None</td> +<td>The table name for storing the schema +version number.</td> +</tr> +<tr class="row-even"><td><strong>migration_auto_latest</strong></td> +<td>FALSE</td> +<td>TRUE / FALSE</td> +<td>Enable or disable automatically +running migrations.</td> +</tr> +<tr class="row-odd"><td><strong>migration_type</strong></td> +<td>‘timestamp’</td> +<td>‘timestamp’ / ‘sequential’</td> +<td>The type of numeric identifier used to name +migration files.</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id5">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Migration"> +<em class="property">class </em><code class="descname">CI_Migration</code><a class="headerlink" href="#CI_Migration" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Migration::current"> +<code class="descname">current</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Migration::current" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE if no migrations are found, current version string on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td> +</tr> +</tbody> +</table> +<p>Migrates up to the current version (whatever is set for +<code class="docutils literal"><span class="pre">$config['migration_version']</span></code> in <em>application/config/migration.php</em>).</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Migration::error_string"> +<code class="descname">error_string</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Migration::error_string" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Error messages</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>This returns a string of errors that were detected while performing a migration.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Migration::find_migrations"> +<code class="descname">find_migrations</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Migration::find_migrations" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array of migration files</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>An array of migration filenames are returned that are found in the <strong>migration_path</strong> property.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Migration::latest"> +<code class="descname">latest</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Migration::latest" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Current version string on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td> +</tr> +</tbody> +</table> +<p>This works much the same way as <code class="docutils literal"><span class="pre">current()</span></code> but instead of looking for +the <code class="docutils literal"><span class="pre">$config['migration_version']</span></code> the Migration class will use the very +newest migration found in the filesystem.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Migration::version"> +<code class="descname">version</code><span class="sig-paren">(</span><em>$target_version</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Migration::version" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$target_version</strong> (<em>mixed</em>) – Migration version to process</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if no migrations are found, current version string on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Version can be used to roll back changes or step forwards programmatically to +specific versions. It works just like <code class="docutils literal"><span class="pre">current()</span></code> but ignores <code class="docutils literal"><span class="pre">$config['migration_version']</span></code>.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">migration</span><span class="o">-></span><span class="na">version</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="output.html" class="btn btn-neutral float-right" title="Output Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="loader.html" class="btn btn-neutral" title="Loader Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html new file mode 100644 index 000000000..a09ac5299 --- /dev/null +++ b/user_guide/libraries/output.html @@ -0,0 +1,912 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Output Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Pagination Class" href="pagination.html"/> + <link rel="prev" title="Migrations Class" href="migration.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Output Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="output-class"> +<h1>Output Class<a class="headerlink" href="#output-class" title="Permalink to this headline">¶</a></h1> +<p>The Output class is a core class with one main function: To send the +finalized web page to the requesting browser. It is also responsible for +<a class="reference internal" href="../general/caching.html"><span class="doc">caching</span></a> your web pages, if you use that +feature.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This class is initialized automatically by the system so there +is no need to do it manually.</p> +</div> +<p>Under normal circumstances you won’t even notice the Output class since +it works transparently without your intervention. For example, when you +use the <a class="reference internal" href="loader.html"><span class="doc">Loader</span></a> class to load a view file, +it’s automatically passed to the Output class, which will be called +automatically by CodeIgniter at the end of system execution. It is +possible, however, for you to manually intervene with the output if you +need to.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#class-reference" id="id1">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id1">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Output"> +<em class="property">class </em><code class="descname">CI_Output</code><a class="headerlink" href="#CI_Output" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$parse_exec_vars = TRUE;</code></dt> +<dd><p>Enables/disables parsing of the {elapsed_time} and {memory_usage} pseudo-variables.</p> +<p>CodeIgniter will parse those tokens in your output by default. To disable this, set +this property to FALSE in your controller.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">parse_exec_vars</span> <span class="o">=</span> <span class="k">FALSE</span><span class="p">;</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::set_output"> +<code class="descname">set_output</code><span class="sig-paren">(</span><em>$output</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::set_output" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$output</strong> (<em>string</em>) – String to set the output to</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to manually set the final output string. Usage example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_output</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">If you do set your output manually, it must be the last thing done +in the function you call it from. For example, if you build a page in one +of your controller methods, don’t set the output until the end.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::set_content_type"> +<code class="descname">set_content_type</code><span class="sig-paren">(</span><em>$mime_type</em><span class="optional">[</span>, <em>$charset = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::set_content_type" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$mime_type</strong> (<em>string</em>) – MIME Type idenitifer string</li> +<li><strong>$charset</strong> (<em>string</em>) – Character set</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set the mime-type of your page so you can serve JSON data, JPEG’s, XML, etc easily.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span> + <span class="o">-></span><span class="na">set_content_type</span><span class="p">(</span><span class="s1">'application/json'</span><span class="p">)</span> + <span class="o">-></span><span class="na">set_output</span><span class="p">(</span><span class="nb">json_encode</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'foo'</span> <span class="o">=></span> <span class="s1">'bar'</span><span class="p">)));</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span> + <span class="o">-></span><span class="na">set_content_type</span><span class="p">(</span><span class="s1">'jpeg'</span><span class="p">)</span> <span class="c1">// You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php</span> + <span class="o">-></span><span class="na">set_output</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'files/something.jpg'</span><span class="p">));</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Make sure any non-mime string you pass to this method +exists in <em>application/config/mimes.php</em> or it will have no effect.</p> +</div> +<p>You can also set the character set of the document, by passing a second argument:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_content_type</span><span class="p">(</span><span class="s1">'css'</span><span class="p">,</span> <span class="s1">'utf-8'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::get_content_type"> +<code class="descname">get_content_type</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::get_content_type" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Content-Type string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns the Content-Type HTTP header that’s currently in use, excluding the character set value.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$mime</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">get_content_type</span><span class="p">();</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If not set, the default return value is ‘text/html’.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::get_header"> +<code class="descname">get_header</code><span class="sig-paren">(</span><em>$header</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::get_header" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$header</strong> (<em>string</em>) – HTTP header name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTTP response header or NULL if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Returns the requested HTTP header value, or NULL if the requested header is not set. +Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_content_type</span><span class="p">(</span><span class="s1">'text/plain'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">get_header</span><span class="p">(</span><span class="s1">'content-type'</span><span class="p">);</span> +<span class="c1">// Outputs: text/plain; charset=utf-8</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The header name is compared in a case-insensitive manner.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Raw headers sent via PHP’s native <code class="docutils literal"><span class="pre">header()</span></code> function are also detected.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::get_output"> +<code class="descname">get_output</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::get_output" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Output string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Permits you to manually retrieve any output that has been sent for +storage in the output class. Usage example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">get_output</span><span class="p">();</span> +</pre></div> +</div> +<p>Note that data will only be retrievable from this function if it has +been previously sent to the output class by one of the CodeIgniter +functions like <code class="docutils literal"><span class="pre">$this->load->view()</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::append_output"> +<code class="descname">append_output</code><span class="sig-paren">(</span><em>$output</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::append_output" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$output</strong> (<em>string</em>) – Additional output data to append</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Appends data onto the output string.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">append_output</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::set_header"> +<code class="descname">set_header</code><span class="sig-paren">(</span><em>$header</em><span class="optional">[</span>, <em>$replace = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::set_header" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$header</strong> (<em>string</em>) – HTTP response header</li> +<li><strong>$replace</strong> (<em>bool</em>) – Whether to replace the old header value, if it is already set</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to manually set server headers, which the output class will +send for you when outputting the final rendered display. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'HTTP/1.0 200 OK'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'HTTP/1.1 200 OK'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'Last-Modified: '</span><span class="o">.</span><span class="nb">gmdate</span><span class="p">(</span><span class="s1">'D, d M Y H:i:s'</span><span class="p">,</span> <span class="nv">$last_update</span><span class="p">)</span><span class="o">.</span><span class="s1">' GMT'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'Cache-Control: no-store, no-cache, must-revalidate'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'Cache-Control: post-check=0, pre-check=0'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_header</span><span class="p">(</span><span class="s1">'Pragma: no-cache'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::set_status_header"> +<code class="descname">set_status_header</code><span class="sig-paren">(</span><span class="optional">[</span><em>$code = 200</em><span class="optional">[</span>, <em>$text = ''</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::set_status_header" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$code</strong> (<em>int</em>) – HTTP status code</li> +<li><strong>$text</strong> (<em>string</em>) – Optional message</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to manually set a server status header. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">set_status_header</span><span class="p">(</span><span class="mi">401</span><span class="p">);</span> +<span class="c1">// Sets the header as: Unauthorized</span> +</pre></div> +</div> +<p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">See here</a> for a full list of headers.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is an alias for <a class="reference internal" href="../general/common_functions.html"><span class="doc">Common function</span></a> +<code class="xref py py-func docutils literal"><span class="pre">set_status_header()</span></code>.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::enable_profiler"> +<code class="descname">enable_profiler</code><span class="sig-paren">(</span><span class="optional">[</span><em>$val = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::enable_profiler" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$val</strong> (<em>bool</em>) – Whether to enable or disable the Profiler</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to enable/disable the <a class="reference internal" href="../general/profiling.html"><span class="doc">Profiler</span></a>, which will display benchmark +and other data at the bottom of your pages for debugging and optimization purposes.</p> +<p>To enable the profiler place the following line anywhere within your +<a class="reference internal" href="../general/controllers.html"><span class="doc">Controller</span></a> methods:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">enable_profiler</span><span class="p">(</span><span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +<p>When enabled a report will be generated and inserted at the bottom of your pages.</p> +<p>To disable the profiler you would use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">output</span><span class="o">-></span><span class="na">enable_profiler</span><span class="p">(</span><span class="k">FALSE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::set_profiler_sections"> +<code class="descname">set_profiler_sections</code><span class="sig-paren">(</span><em>$sections</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::set_profiler_sections" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$sections</strong> (<em>array</em>) – Profiler sections</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to enable/disable specific sections of the Profiler when it is enabled. +Please refer to the <a class="reference internal" href="../general/profiling.html"><span class="doc">Profiler</span></a> documentation for further information.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::cache"> +<code class="descname">cache</code><span class="sig-paren">(</span><em>$time</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::cache" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$time</strong> (<em>int</em>) – Cache expiration time in minutes</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Output instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Output</p> +</td> +</tr> +</tbody> +</table> +<p>Caches the current page for the specified amount of minutes.</p> +<p>For more information, please see the <a class="reference internal" href="../general/caching.html"><span class="doc">caching documentation</span></a>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Output::_display"> +<code class="descname">_display</code><span class="sig-paren">(</span><span class="optional">[</span><em>$output = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Output::_display" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$output</strong> (<em>string</em>) – Output data override</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">void</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sends finalized output data to the browser along with any server headers. It also stops benchmark +timers.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is called automatically at the end of script execution, you won’t need to +call it manually unless you are aborting script execution using <code class="docutils literal"><span class="pre">exit()</span></code> or <code class="docutils literal"><span class="pre">die()</span></code> in your code.</p> +</div> +<p>Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'status'</span> <span class="o">=></span> <span class="s1">'OK'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">output</span> + <span class="o">-></span><span class="na">set_status_header</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> + <span class="o">-></span><span class="na">set_content_type</span><span class="p">(</span><span class="s1">'application/json'</span><span class="p">,</span> <span class="s1">'utf-8'</span><span class="p">)</span> + <span class="o">-></span><span class="na">set_output</span><span class="p">(</span><span class="nb">json_encode</span><span class="p">(</span><span class="nv">$response</span><span class="p">,</span> <span class="nx">JSON_PRETTY_PRINT</span> <span class="o">|</span> <span class="nx">JSON_UNESCAPED_UNICODE</span> <span class="o">|</span> <span class="nx">JSON_UNESCAPED_SLASHES</span><span class="p">))</span> + <span class="o">-></span><span class="na">_display</span><span class="p">();</span> +<span class="k">exit</span><span class="p">;</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Calling this method manually without aborting script execution will result in duplicated output.</p> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="pagination.html" class="btn btn-neutral float-right" title="Pagination Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="migration.html" class="btn btn-neutral" title="Migrations Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html new file mode 100644 index 000000000..9ff339d3b --- /dev/null +++ b/user_guide/libraries/pagination.html @@ -0,0 +1,784 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Pagination Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Template Parser Class" href="parser.html"/> + <link rel="prev" title="Output Class" href="output.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Pagination Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="pagination-class"> +<h1>Pagination Class<a class="headerlink" href="#pagination-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s Pagination class is very easy to use, and it is 100% +customizable, either dynamically or via stored preferences.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#example" id="id1">Example</a><ul> +<li><a class="reference internal" href="#notes" id="id2">Notes</a></li> +<li><a class="reference internal" href="#setting-preferences-in-a-config-file" id="id3">Setting preferences in a config file</a></li> +</ul> +</li> +<li><a class="reference internal" href="#customizing-the-pagination" id="id4">Customizing the Pagination</a></li> +<li><a class="reference internal" href="#adding-enclosing-markup" id="id5">Adding Enclosing Markup</a></li> +<li><a class="reference internal" href="#customizing-the-first-link" id="id6">Customizing the First Link</a></li> +<li><a class="reference internal" href="#customizing-the-last-link" id="id7">Customizing the Last Link</a></li> +<li><a class="reference internal" href="#customizing-the-next-link" id="id8">Customizing the “Next” Link</a></li> +<li><a class="reference internal" href="#customizing-the-previous-link" id="id9">Customizing the “Previous” Link</a></li> +<li><a class="reference internal" href="#customizing-the-current-page-link" id="id10">Customizing the “Current Page” Link</a></li> +<li><a class="reference internal" href="#customizing-the-digit-link" id="id11">Customizing the “Digit” Link</a></li> +<li><a class="reference internal" href="#hiding-the-pages" id="id12">Hiding the Pages</a></li> +<li><a class="reference internal" href="#adding-attributes-to-anchors" id="id13">Adding attributes to anchors</a></li> +<li><a class="reference internal" href="#disabling-the-rel-attribute" id="id14">Disabling the “rel” attribute</a></li> +<li><a class="reference internal" href="#class-reference" id="id15">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><p>If you are not familiar with the term “pagination”, it refers to links +that allows you to navigate from page to page, like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">«</span> <span class="nx">First </span><span class="o"><</span><span class="nx"> 1 2 3 4 5 </span><span class="o">></span><span class="nx"> Last</span> <span class="nx">»</span> +</pre></div> +</div> +<div class="section" id="example"> +<h2><a class="toc-backref" href="#id1">Example</a><a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> +<p>Here is a simple example showing how to create pagination in one of your +<a class="reference internal" href="../general/controllers.html"><span class="doc">controller</span></a> methods:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'pagination'</span><span class="p">);</span> + +<span class="nv">$config</span><span class="p">[</span><span class="s1">'base_url'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'http://example.com/index.php/test/page/'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'total_rows'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">200</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'per_page'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">20</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">pagination</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">pagination</span><span class="o">-></span><span class="na">create_links</span><span class="p">();</span> +</pre></div> +</div> +<div class="section" id="notes"> +<h3><a class="toc-backref" href="#id2">Notes</a><a class="headerlink" href="#notes" title="Permalink to this headline">¶</a></h3> +<p>The <code class="docutils literal"><span class="pre">$config</span></code> array contains your configuration variables. It is passed to +the <code class="docutils literal"><span class="pre">$this->pagination->initialize()</span></code> method as shown above. Although +there are some twenty items you can configure, at minimum you need the +three shown. Here is a description of what those items represent:</p> +<ul class="simple"> +<li><strong>base_url</strong> This is the full URL to the controller class/function +containing your pagination. In the example above, it is pointing to a +controller called “Test” and a function called “page”. Keep in mind +that you can <a class="reference internal" href="../general/routing.html"><span class="doc">re-route your URI</span></a> if you +need a different structure.</li> +<li><strong>total_rows</strong> This number represents the total rows in the result +set you are creating pagination for. Typically this number will be +the total rows that your database query returned.</li> +<li><strong>per_page</strong> The number of items you intend to show per page. In the +above example, you would be showing 20 items per page.</li> +</ul> +<p>The <code class="docutils literal"><span class="pre">create_links()</span></code> method returns an empty string when there is no +pagination to show.</p> +</div> +<div class="section" id="setting-preferences-in-a-config-file"> +<h3><a class="toc-backref" href="#id3">Setting preferences in a config file</a><a class="headerlink" href="#setting-preferences-in-a-config-file" title="Permalink to this headline">¶</a></h3> +<p>If you prefer not to set preferences using the above method, you can +instead put them into a config file. Simply create a new file called +pagination.php, add the <code class="docutils literal"><span class="pre">$config</span></code> array in that file. Then save the file +in <em>application/config/pagination.php</em> and it will be used automatically. +You will NOT need to use <code class="docutils literal"><span class="pre">$this->pagination->initialize()</span></code> if you save +your preferences in a config file.</p> +</div> +</div> +<div class="section" id="customizing-the-pagination"> +<h2><a class="toc-backref" href="#id4">Customizing the Pagination</a><a class="headerlink" href="#customizing-the-pagination" title="Permalink to this headline">¶</a></h2> +<p>The following is a list of all the preferences you can pass to the +initialization function to tailor the display.</p> +<p><strong>$config[‘uri_segment’] = 3;</strong></p> +<p>The pagination function automatically determines which segment of your +URI contains the page number. If you need something different you can +specify it.</p> +<p><strong>$config[‘num_links’] = 2;</strong></p> +<p>The number of “digit” links you would like before and after the selected +page number. For example, the number 2 will place two digits on either +side, as in the example links at the very top of this page.</p> +<p><strong>$config[‘use_page_numbers’] = TRUE;</strong></p> +<p>By default, the URI segment will use the starting index for the items +you are paginating. If you prefer to show the the actual page number, +set this to TRUE.</p> +<p><strong>$config[‘page_query_string’] = TRUE;</strong></p> +<p>By default, the pagination library assume you are using <a class="reference internal" href="../general/urls.html"><span class="doc">URI +Segments</span></a>, and constructs your links something +like:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">test</span><span class="o">/</span><span class="nx">page</span><span class="o">/</span><span class="mi">20</span> +</pre></div> +</div> +<p>If you have <code class="docutils literal"><span class="pre">$config['enable_query_strings']</span></code> set to TRUE your links +will automatically be re-written using Query Strings. This option can +also be explicitly set. Using <code class="docutils literal"><span class="pre">$config['page_query_string']</span></code> set to TRUE, +the pagination link will become:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">?</span><span class="nx">c</span><span class="o">=</span><span class="nx">test</span><span class="o">&</span><span class="nx">m</span><span class="o">=</span><span class="nx">page</span><span class="o">&</span><span class="nx">per_page</span><span class="o">=</span><span class="mi">20</span> +</pre></div> +</div> +<p>Note that “per_page” is the default query string passed, however can be +configured using <code class="docutils literal"><span class="pre">$config['query_string_segment']</span> <span class="pre">=</span> <span class="pre">'your_string'</span></code></p> +<p><strong>$config[‘reuse_query_string’] = FALSE;</strong></p> +<p>By default your Query String arguments (nothing to do with other +query string options) will be ignored. Setting this config to +TRUE will add existing query string arguments back into the +URL after the URI segment and before the suffix.:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">test</span><span class="o">/</span><span class="nx">page</span><span class="o">/</span><span class="mi">20</span><span class="o">?</span><span class="nx">query</span><span class="o">=</span><span class="nx">search</span><span class="o">%</span><span class="nx">term</span> +</pre></div> +</div> +<p>This helps you mix together normal <a class="reference internal" href="../general/urls.html"><span class="doc">URI Segments</span></a> +as well as query string arguments, which until 3.0 was not possible.</p> +<p><strong>$config[‘prefix’] = ‘’;</strong></p> +<p>A custom prefix added to the path. The prefix value will be right before +the offset segment.</p> +<p><strong>$config[‘suffix’] = ‘’;</strong></p> +<p>A custom suffix added to the path. The suffix value will be right after +the offset segment.</p> +<p><strong>$config[‘use_global_url_suffix’] = FALSE;</strong></p> +<p>When set to TRUE, it will <strong>override</strong> the <code class="docutils literal"><span class="pre">$config['suffix']</span></code> value and +instead set it to the one that you have in <code class="docutils literal"><span class="pre">$config['url_suffix']</span></code> in +your <strong>application/config/config.php</strong> file.</p> +</div> +<div class="section" id="adding-enclosing-markup"> +<h2><a class="toc-backref" href="#id5">Adding Enclosing Markup</a><a class="headerlink" href="#adding-enclosing-markup" title="Permalink to this headline">¶</a></h2> +<p>If you would like to surround the entire pagination with some markup you +can do it with these two preferences:</p> +<p><strong>$config[‘full_tag_open’] = ‘<p>’;</strong></p> +<p>The opening tag placed on the left side of the entire result.</p> +<p><strong>$config[‘full_tag_close’] = ‘</p>’;</strong></p> +<p>The closing tag placed on the right side of the entire result.</p> +</div> +<div class="section" id="customizing-the-first-link"> +<h2><a class="toc-backref" href="#id6">Customizing the First Link</a><a class="headerlink" href="#customizing-the-first-link" title="Permalink to this headline">¶</a></h2> +<p><strong>$config[‘first_link’] = ‘First’;</strong></p> +<p>The text you would like shown in the “first” link on the left. If you do +not want this link rendered, you can set its value to FALSE.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This value can also be translated via a language file.</p> +</div> +<p><strong>$config[‘first_tag_open’] = ‘<div>’;</strong></p> +<p>The opening tag for the “first” link.</p> +<p><strong>$config[‘first_tag_close’] = ‘</div>’;</strong></p> +<p>The closing tag for the “first” link.</p> +<p><strong>$config[‘first_url’] = ‘’;</strong></p> +<p>An alternative URL to use for the “first page” link.</p> +</div> +<div class="section" id="customizing-the-last-link"> +<h2><a class="toc-backref" href="#id7">Customizing the Last Link</a><a class="headerlink" href="#customizing-the-last-link" title="Permalink to this headline">¶</a></h2> +<p><strong>$config[‘last_link’] = ‘Last’;</strong></p> +<p>The text you would like shown in the “last” link on the right. If you do +not want this link rendered, you can set its value to FALSE.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This value can also be translated via a language file.</p> +</div> +<p><strong>$config[‘last_tag_open’] = ‘<div>’;</strong></p> +<p>The opening tag for the “last” link.</p> +<p><strong>$config[‘last_tag_close’] = ‘</div>’;</strong></p> +<p>The closing tag for the “last” link.</p> +</div> +<div class="section" id="customizing-the-next-link"> +<h2><a class="toc-backref" href="#id8">Customizing the “Next” Link</a><a class="headerlink" href="#customizing-the-next-link" title="Permalink to this headline">¶</a></h2> +<p><strong>$config[‘next_link’] = ‘&gt;’;</strong></p> +<p>The text you would like shown in the “next” page link. If you do not +want this link rendered, you can set its value to FALSE.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This value can also be translated via a language file.</p> +</div> +<p><strong>$config[‘next_tag_open’] = ‘<div>’;</strong></p> +<p>The opening tag for the “next” link.</p> +<p><strong>$config[‘next_tag_close’] = ‘</div>’;</strong></p> +<p>The closing tag for the “next” link.</p> +</div> +<div class="section" id="customizing-the-previous-link"> +<h2><a class="toc-backref" href="#id9">Customizing the “Previous” Link</a><a class="headerlink" href="#customizing-the-previous-link" title="Permalink to this headline">¶</a></h2> +<p><strong>$config[‘prev_link’] = ‘&lt;’;</strong></p> +<p>The text you would like shown in the “previous” page link. If you do not +want this link rendered, you can set its value to FALSE.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This value can also be translated via a language file.</p> +</div> +<p><strong>$config[‘prev_tag_open’] = ‘<div>’;</strong></p> +<p>The opening tag for the “previous” link.</p> +<p><strong>$config[‘prev_tag_close’] = ‘</div>’;</strong></p> +<p>The closing tag for the “previous” link.</p> +</div> +<div class="section" id="customizing-the-current-page-link"> +<h2><a class="toc-backref" href="#id10">Customizing the “Current Page” Link</a><a class="headerlink" href="#customizing-the-current-page-link" title="Permalink to this headline">¶</a></h2> +<p><strong>$config[‘cur_tag_open’] = ‘<b>’;</strong></p> +<p>The opening tag for the “current” link.</p> +<p><strong>$config[‘cur_tag_close’] = ‘</b>’;</strong></p> +<p>The closing tag for the “current” link.</p> +</div> +<div class="section" id="customizing-the-digit-link"> +<h2><a class="toc-backref" href="#id11">Customizing the “Digit” Link</a><a class="headerlink" href="#customizing-the-digit-link" title="Permalink to this headline">¶</a></h2> +<p><strong>$config[‘num_tag_open’] = ‘<div>’;</strong></p> +<p>The opening tag for the “digit” link.</p> +<p><strong>$config[‘num_tag_close’] = ‘</div>’;</strong></p> +<p>The closing tag for the “digit” link.</p> +</div> +<div class="section" id="hiding-the-pages"> +<h2><a class="toc-backref" href="#id12">Hiding the Pages</a><a class="headerlink" href="#hiding-the-pages" title="Permalink to this headline">¶</a></h2> +<p>If you wanted to not list the specific pages (for example, you only want +“next” and “previous” links), you can suppress their rendering by +adding:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'display_pages'</span><span class="p">]</span> <span class="o">=</span> <span class="k">FALSE</span><span class="p">;</span> +</pre></div> +</div> +</div> +<div class="section" id="adding-attributes-to-anchors"> +<h2><a class="toc-backref" href="#id13">Adding attributes to anchors</a><a class="headerlink" href="#adding-attributes-to-anchors" title="Permalink to this headline">¶</a></h2> +<p>If you want to add an extra attribute to be added to every link rendered +by the pagination class, you can set them as key/value pairs in the +“attributes” config:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Produces: class="myclass"</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'attributes'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'class'</span> <span class="o">=></span> <span class="s1">'myclass'</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Usage of the old method of setting classes via “anchor_class” +is deprecated.</p> +</div> +</div> +<div class="section" id="disabling-the-rel-attribute"> +<h2><a class="toc-backref" href="#id14">Disabling the “rel” attribute</a><a class="headerlink" href="#disabling-the-rel-attribute" title="Permalink to this headline">¶</a></h2> +<p>By default the rel attribute is dynamically generated and appended to +the appropriate anchors. If for some reason you want to turn it off, +you can pass boolean FALSE as a regular attribute</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'attributes'</span><span class="p">][</span><span class="s1">'rel'</span><span class="p">]</span> <span class="o">=</span> <span class="k">FALSE</span><span class="p">;</span> +</pre></div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id15">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Pagination"> +<em class="property">class </em><code class="descname">CI_Pagination</code><a class="headerlink" href="#CI_Pagination" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Pagination::initialize"> +<code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>$params = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Pagination::initialize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$params</strong> (<em>array</em>) – Configuration parameters</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Pagination instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Pagination</p> +</td> +</tr> +</tbody> +</table> +<p>Initializes the Pagination class with your preferred options.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Pagination::create_links"> +<code class="descname">create_links</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Pagination::create_links" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">HTML-formatted pagination</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a “pagination” bar, containing the generated links or an empty string if there’s just a single page.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="parser.html" class="btn btn-neutral float-right" title="Template Parser Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="output.html" class="btn btn-neutral" title="Output Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/parser.html b/user_guide/libraries/parser.html new file mode 100644 index 000000000..d03a3d201 --- /dev/null +++ b/user_guide/libraries/parser.html @@ -0,0 +1,850 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Template Parser Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Security Class" href="security.html"/> + <link rel="prev" title="Pagination Class" href="pagination.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Template Parser Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="template-parser-class"> +<h1>Template Parser Class<a class="headerlink" href="#template-parser-class" title="Permalink to this headline">¶</a></h1> +<p>The Template Parser Class can perform simple text substitution for +pseudo-variables contained within your view files. +It can parse simple variables or variable tag pairs.</p> +<p>If you’ve never used a template engine, +pseudo-variable names are enclosed in braces, like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> + <span class="o"><</span><span class="nx">head</span><span class="o">></span> + <span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="p">{</span><span class="nx">blog_title</span><span class="p">}</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> + <span class="o"></</span><span class="nx">head</span><span class="o">></span> + <span class="o"><</span><span class="nx">body</span><span class="o">></span> + <span class="o"><</span><span class="nx">h3</span><span class="o">></span><span class="p">{</span><span class="nx">blog_heading</span><span class="p">}</span><span class="o"></</span><span class="nx">h3</span><span class="o">></span> + + <span class="p">{</span><span class="nx">blog_entries</span><span class="p">}</span> + <span class="o"><</span><span class="nx">h5</span><span class="o">></span><span class="p">{</span><span class="nx">title</span><span class="p">}</span><span class="o"></</span><span class="nx">h5</span><span class="o">></span> + <span class="o"><</span><span class="nx">p</span><span class="o">></span><span class="p">{</span><span class="nx">body</span><span class="p">}</span><span class="o"></</span><span class="nx">p</span><span class="o">></span> + <span class="p">{</span><span class="o">/</span><span class="nx">blog_entries</span><span class="p">}</span> + + <span class="o"></</span><span class="nx">body</span><span class="o">></span> +<span class="o"></</span><span class="nx">html</span><span class="o">></span> +</pre></div> +</div> +<p>These variables are not actual PHP variables, but rather plain text +representations that allow you to eliminate PHP from your templates +(view files).</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">CodeIgniter does <strong>not</strong> require you to use this class since +using pure PHP in your view pages lets them run a little faster. +However, some developers prefer to use a template engine if +they work with designers who they feel would find some +confusion working with PHP.</p> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The Template Parser Class is <strong>not</strong> a full-blown +template parsing solution. We’ve kept it very lean on purpose in order +to maintain maximum performance.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-template-parser-class" id="id1">Using the Template Parser Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#parsing-templates" id="id3">Parsing templates</a></li> +<li><a class="reference internal" href="#variable-pairs" id="id4">Variable Pairs</a></li> +<li><a class="reference internal" href="#usage-notes" id="id5">Usage Notes</a></li> +<li><a class="reference internal" href="#view-fragments" id="id6">View Fragments</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id7">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-template-parser-class"> +<h2><a class="toc-backref" href="#id1">Using the Template Parser Class</a><a class="headerlink" href="#using-the-template-parser-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Parser class is initialized +in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'parser'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Parser library object will be available using: +$this->parser</p> +</div> +<div class="section" id="parsing-templates"> +<h3><a class="toc-backref" href="#id3">Parsing templates</a><a class="headerlink" href="#parsing-templates" title="Permalink to this headline">¶</a></h3> +<p>You can use the <code class="docutils literal"><span class="pre">parse()</span></code> method to parse (or render) simple templates, +like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'blog_title'</span> <span class="o">=></span> <span class="s1">'My Blog Title'</span><span class="p">,</span> + <span class="s1">'blog_heading'</span> <span class="o">=></span> <span class="s1">'My Blog Heading'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse</span><span class="p">(</span><span class="s1">'blog_template'</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>The first parameter contains the name of the <a class="reference internal" href="../general/views.html"><span class="doc">view +file</span></a> (in this example the file would be called +blog_template.php), and the second parameter contains an associative +array of data to be replaced in the template. In the above example, the +template would contain two variables: {blog_title} and {blog_heading}</p> +<p>There is no need to “echo” or do something with the data returned by +$this->parser->parse(). It is automatically passed to the output class +to be sent to the browser. However, if you do want the data returned +instead of sent to the output class you can pass TRUE (boolean) as the +third parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse</span><span class="p">(</span><span class="s1">'blog_template'</span><span class="p">,</span> <span class="nv">$data</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="variable-pairs"> +<h3><a class="toc-backref" href="#id4">Variable Pairs</a><a class="headerlink" href="#variable-pairs" title="Permalink to this headline">¶</a></h3> +<p>The above example code allows simple variables to be replaced. What if +you would like an entire block of variables to be repeated, with each +iteration containing new values? Consider the template example we showed +at the top of the page:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">html</span><span class="o">></span> + <span class="o"><</span><span class="nx">head</span><span class="o">></span> + <span class="o"><</span><span class="nx">title</span><span class="o">></span><span class="p">{</span><span class="nx">blog_title</span><span class="p">}</span><span class="o"></</span><span class="nx">title</span><span class="o">></span> + <span class="o"></</span><span class="nx">head</span><span class="o">></span> + <span class="o"><</span><span class="nx">body</span><span class="o">></span> + <span class="o"><</span><span class="nx">h3</span><span class="o">></span><span class="p">{</span><span class="nx">blog_heading</span><span class="p">}</span><span class="o"></</span><span class="nx">h3</span><span class="o">></span> + + <span class="p">{</span><span class="nx">blog_entries</span><span class="p">}</span> + <span class="o"><</span><span class="nx">h5</span><span class="o">></span><span class="p">{</span><span class="nx">title</span><span class="p">}</span><span class="o"></</span><span class="nx">h5</span><span class="o">></span> + <span class="o"><</span><span class="nx">p</span><span class="o">></span><span class="p">{</span><span class="nx">body</span><span class="p">}</span><span class="o"></</span><span class="nx">p</span><span class="o">></span> + <span class="p">{</span><span class="o">/</span><span class="nx">blog_entries</span><span class="p">}</span> + + <span class="o"></</span><span class="nx">body</span><span class="o">></span> +<span class="o"></</span><span class="nx">html</span><span class="o">></span> +</pre></div> +</div> +<p>In the above code you’ll notice a pair of variables: {blog_entries} +data… {/blog_entries}. In a case like this, the entire chunk of data +between these pairs would be repeated multiple times, corresponding to +the number of rows in the “blog_entries” element of the parameters array.</p> +<p>Parsing variable pairs is done using the identical code shown above to +parse single variables, except, you will add a multi-dimensional array +corresponding to your variable pair data. Consider this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'parser'</span><span class="p">);</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'blog_title'</span> <span class="o">=></span> <span class="s1">'My Blog Title'</span><span class="p">,</span> + <span class="s1">'blog_heading'</span> <span class="o">=></span> <span class="s1">'My Blog Heading'</span><span class="p">,</span> + <span class="s1">'blog_entries'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Title 1'</span><span class="p">,</span> <span class="s1">'body'</span> <span class="o">=></span> <span class="s1">'Body 1'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Title 2'</span><span class="p">,</span> <span class="s1">'body'</span> <span class="o">=></span> <span class="s1">'Body 2'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Title 3'</span><span class="p">,</span> <span class="s1">'body'</span> <span class="o">=></span> <span class="s1">'Body 3'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Title 4'</span><span class="p">,</span> <span class="s1">'body'</span> <span class="o">=></span> <span class="s1">'Body 4'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Title 5'</span><span class="p">,</span> <span class="s1">'body'</span> <span class="o">=></span> <span class="s1">'Body 5'</span><span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse</span><span class="p">(</span><span class="s1">'blog_template'</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>If your “pair” data is coming from a database result, which is already a +multi-dimensional array, you can simply use the database <code class="docutils literal"><span class="pre">result_array()</span></code> +method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">db</span><span class="o">-></span><span class="na">query</span><span class="p">(</span><span class="s2">"SELECT * FROM blog"</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'parser'</span><span class="p">);</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'blog_title'</span> <span class="o">=></span> <span class="s1">'My Blog Title'</span><span class="p">,</span> + <span class="s1">'blog_heading'</span> <span class="o">=></span> <span class="s1">'My Blog Heading'</span><span class="p">,</span> + <span class="s1">'blog_entries'</span> <span class="o">=></span> <span class="nv">$query</span><span class="o">-></span><span class="na">result_array</span><span class="p">()</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse</span><span class="p">(</span><span class="s1">'blog_template'</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="usage-notes"> +<h3><a class="toc-backref" href="#id5">Usage Notes</a><a class="headerlink" href="#usage-notes" title="Permalink to this headline">¶</a></h3> +<p>If you include substitution parameters that are not referenced in your +template, they are ignored:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="s1">'Hello, {firstname} {lastname}'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Mr'</span><span class="p">,</span> + <span class="s1">'firstname'</span> <span class="o">=></span> <span class="s1">'John'</span><span class="p">,</span> + <span class="s1">'lastname'</span> <span class="o">=></span> <span class="s1">'Doe'</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="c1">// Result: Hello, John Doe</span> +</pre></div> +</div> +<p>If you do not include a substitution parameter that is referenced in your +template, the original pseudo-variable is shown in the result:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="s1">'Hello, {firstname} {initials} {lastname}'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Mr'</span><span class="p">,</span> + <span class="s1">'firstname'</span> <span class="o">=></span> <span class="s1">'John'</span><span class="p">,</span> + <span class="s1">'lastname'</span> <span class="o">=></span> <span class="s1">'Doe'</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="c1">// Result: Hello, John {initials} Doe</span> +</pre></div> +</div> +<p>If you provide a string substitution parameter when an array is expected, +i.e. for a variable pair, the substitution is done for the opening variable +pair tag, but the closing variable pair tag is not rendered properly:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="s1">'Hello, {firstname} {lastname} ({degrees}{degree} {/degrees})'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'degrees'</span> <span class="o">=></span> <span class="s1">'Mr'</span><span class="p">,</span> + <span class="s1">'firstname'</span> <span class="o">=></span> <span class="s1">'John'</span><span class="p">,</span> + <span class="s1">'lastname'</span> <span class="o">=></span> <span class="s1">'Doe'</span><span class="p">,</span> + <span class="s1">'titles'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'degree'</span> <span class="o">=></span> <span class="s1">'BSc'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'degree'</span> <span class="o">=></span> <span class="s1">'PhD'</span><span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="c1">// Result: Hello, John Doe (Mr{degree} {/degrees})</span> +</pre></div> +</div> +<p>If you name one of your individual substitution parameters the same as one +used inside a variable pair, the results may not be as expected:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="s1">'Hello, {firstname} {lastname} ({degrees}{degree} {/degrees})'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'degree'</span> <span class="o">=></span> <span class="s1">'Mr'</span><span class="p">,</span> + <span class="s1">'firstname'</span> <span class="o">=></span> <span class="s1">'John'</span><span class="p">,</span> + <span class="s1">'lastname'</span> <span class="o">=></span> <span class="s1">'Doe'</span><span class="p">,</span> + <span class="s1">'degrees'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'degree'</span> <span class="o">=></span> <span class="s1">'BSc'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'degree'</span> <span class="o">=></span> <span class="s1">'PhD'</span><span class="p">)</span> + <span class="p">)</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="c1">// Result: Hello, John Doe (Mr Mr )</span> +</pre></div> +</div> +</div> +<div class="section" id="view-fragments"> +<h3><a class="toc-backref" href="#id6">View Fragments</a><a class="headerlink" href="#view-fragments" title="Permalink to this headline">¶</a></h3> +<p>You do not have to use variable pairs to get the effect of iteration in +your views. It is possible to use a view fragment for what would be inside +a variable pair, and to control the iteration in your controller instead +of in the view.</p> +<p>An example with the iteration controlled in the view:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="s1">'<ul>{menuitems}</span> +<span class="s1"> <li><a href="{link}">{title}</a></li></span> +<span class="s1">{/menuitems}</ul>'</span><span class="p">;</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'menuitems'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'First Link'</span><span class="p">,</span> <span class="s1">'link'</span> <span class="o">=></span> <span class="s1">'/first'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Second Link'</span><span class="p">,</span> <span class="s1">'link'</span> <span class="o">=></span> <span class="s1">'/second'</span><span class="p">),</span> + <span class="p">)</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>Result:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">ul</span><span class="o">></span> + <span class="o"><</span><span class="nx">li</span><span class="o">><</span><span class="nx">a</span> <span class="nx">href</span><span class="o">=</span><span class="s2">"/first"</span><span class="o">></span><span class="nx">First</span> <span class="nx">Link</span><span class="o"></</span><span class="nx">a</span><span class="o">></</span><span class="nx">li</span><span class="o">></span> + <span class="o"><</span><span class="nx">li</span><span class="o">><</span><span class="nx">a</span> <span class="nx">href</span><span class="o">=</span><span class="s2">"/second"</span><span class="o">></span><span class="nx">Second</span> <span class="nx">Link</span><span class="o"></</span><span class="nx">a</span><span class="o">></</span><span class="nx">li</span><span class="o">></span> +<span class="o"></</span><span class="nx">ul</span><span class="o">></span> +</pre></div> +</div> +<p>An example with the iteration controlled in the controller, +using a view fragment:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$temp</span> <span class="o">=</span> <span class="s1">''</span><span class="p">;</span> +<span class="nv">$template1</span> <span class="o">=</span> <span class="s1">'<li><a href="{link}">{title}</a></li>'</span><span class="p">;</span> +<span class="nv">$data1</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'First Link'</span><span class="p">,</span> <span class="s1">'link'</span> <span class="o">=></span> <span class="s1">'/first'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'Second Link'</span><span class="p">,</span> <span class="s1">'link'</span> <span class="o">=></span> <span class="s1">'/second'</span><span class="p">),</span> +<span class="p">);</span> + +<span class="k">foreach</span> <span class="p">(</span><span class="nv">$data1</span> <span class="k">as</span> <span class="nv">$menuitem</span><span class="p">)</span> +<span class="p">{</span> + <span class="nv">$temp</span> <span class="o">.=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template1</span><span class="p">,</span> <span class="nv">$menuitem</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +<span class="p">}</span> + +<span class="nv">$template</span> <span class="o">=</span> <span class="s1">'<ul>{menuitems}</ul>'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'menuitems'</span> <span class="o">=></span> <span class="nv">$temp</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">parser</span><span class="o">-></span><span class="na">parse_string</span><span class="p">(</span><span class="nv">$template</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>Result:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">ul</span><span class="o">></span> + <span class="o"><</span><span class="nx">li</span><span class="o">><</span><span class="nx">a</span> <span class="nx">href</span><span class="o">=</span><span class="s2">"/first"</span><span class="o">></span><span class="nx">First</span> <span class="nx">Link</span><span class="o"></</span><span class="nx">a</span><span class="o">></</span><span class="nx">li</span><span class="o">></span> + <span class="o"><</span><span class="nx">li</span><span class="o">><</span><span class="nx">a</span> <span class="nx">href</span><span class="o">=</span><span class="s2">"/second"</span><span class="o">></span><span class="nx">Second</span> <span class="nx">Link</span><span class="o"></</span><span class="nx">a</span><span class="o">></</span><span class="nx">li</span><span class="o">></span> +<span class="o"></</span><span class="nx">ul</span><span class="o">></span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id7">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Parser"> +<em class="property">class </em><code class="descname">CI_Parser</code><a class="headerlink" href="#CI_Parser" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Parser::parse"> +<code class="descname">parse</code><span class="sig-paren">(</span><em>$template</em>, <em>$data</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Parser::parse" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$template</strong> (<em>string</em>) – Path to view file</li> +<li><strong>$data</strong> (<em>array</em>) – Variable data</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to only return the parsed template</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Parsed template string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Parses a template from the provided path and variables.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Parser::parse_string"> +<code class="descname">parse_string</code><span class="sig-paren">(</span><em>$template</em>, <em>$data</em><span class="optional">[</span>, <em>$return = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Parser::parse_string" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$template</strong> (<em>string</em>) – Path to view file</li> +<li><strong>$data</strong> (<em>array</em>) – Variable data</li> +<li><strong>$return</strong> (<em>bool</em>) – Whether to only return the parsed template</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Parsed template string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>This method works exactly like <code class="docutils literal"><span class="pre">parse()</span></code>, only it accepts +the template as a string instead of loading a view file.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Parser::set_delimiters"> +<code class="descname">set_delimiters</code><span class="sig-paren">(</span><span class="optional">[</span><em>$l = '{'</em><span class="optional">[</span>, <em>$r = '}'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Parser::set_delimiters" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$l</strong> (<em>string</em>) – Left delimiter</li> +<li><strong>$r</strong> (<em>string</em>) – Right delimiter</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the delimiters (opening and closing) for a +pseudo-variable “tag” in a template.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="security.html" class="btn btn-neutral float-right" title="Security Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="pagination.html" class="btn btn-neutral" title="Pagination Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/security.html b/user_guide/libraries/security.html new file mode 100644 index 000000000..0ecc33724 --- /dev/null +++ b/user_guide/libraries/security.html @@ -0,0 +1,739 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Security Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Session Library" href="sessions.html"/> + <link rel="prev" title="Template Parser Class" href="parser.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Security Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="security-class"> +<h1>Security Class<a class="headerlink" href="#security-class" title="Permalink to this headline">¶</a></h1> +<p>The Security Class contains methods that help you create a secure +application, processing input data for security.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#xss-filtering" id="id1">XSS Filtering</a></li> +<li><a class="reference internal" href="#cross-site-request-forgery-csrf" id="id2">Cross-site request forgery (CSRF)</a></li> +<li><a class="reference internal" href="#class-reference" id="id3">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="xss-filtering"> +<h2><a class="toc-backref" href="#id1">XSS Filtering</a><a class="headerlink" href="#xss-filtering" title="Permalink to this headline">¶</a></h2> +<p>CodeIgniter comes with a Cross Site Scripting prevention filter, which +looks for commonly used techniques to trigger JavaScript or other types +of code that attempt to hijack cookies or do other malicious things. +If anything disallowed is encountered it is rendered safe by converting +the data to character entities.</p> +<p>To filter data through the XSS filter use the <code class="docutils literal"><span class="pre">xss_clean()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">security</span><span class="o">-></span><span class="na">xss_clean</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>An optional second parameter, <em>is_image</em>, allows this function to be used +to test images for potential XSS attacks, useful for file upload +security. When this second parameter is set to TRUE, instead of +returning an altered string, the function returns TRUE if the image is +safe, and FALSE if it contained potentially malicious information that a +browser may attempt to execute.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">security</span><span class="o">-></span><span class="na">xss_clean</span><span class="p">(</span><span class="nv">$file</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">)</span> <span class="o">===</span> <span class="k">FALSE</span><span class="p">)</span> +<span class="p">{</span> + <span class="c1">// file failed the XSS test</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">If you want to filter HTML attribute values, use +<a class="reference internal" href="../general/common_functions.html#html_escape" title="html_escape"><code class="xref php php-func docutils literal"><span class="pre">html_escape()</span></code></a> instead!</p> +</div> +</div> +<div class="section" id="cross-site-request-forgery-csrf"> +<h2><a class="toc-backref" href="#id2">Cross-site request forgery (CSRF)</a><a class="headerlink" href="#cross-site-request-forgery-csrf" title="Permalink to this headline">¶</a></h2> +<p>You can enable CSRF protection by altering your <strong>application/config/config.php</strong> +file in the following way:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'csrf_protection'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +</pre></div> +</div> +<p>If you use the <a class="reference internal" href="../helpers/form_helper.html"><span class="doc">form helper</span></a>, then +<code class="xref py py-func docutils literal"><span class="pre">form_open()</span></code> will automatically insert a hidden csrf field in +your forms. If not, then you can use <code class="docutils literal"><span class="pre">get_csrf_token_name()</span></code> +and <code class="docutils literal"><span class="pre">get_csrf_hash()</span></code></p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$csrf</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">security</span><span class="o">-></span><span class="na">get_csrf_token_name</span><span class="p">(),</span> + <span class="s1">'hash'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">security</span><span class="o">-></span><span class="na">get_csrf_hash</span><span class="p">()</span> +<span class="p">);</span> + +<span class="o">...</span> + +<span class="o"><</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">"hidden"</span> <span class="nx">name</span><span class="o">=</span><span class="s2">"<?=</span><span class="si">$csrf['name']</span><span class="s2">;?>"</span> <span class="nx">value</span><span class="o">=</span><span class="s2">"<?=</span><span class="si">$csrf['hash']</span><span class="s2">;?>"</span> <span class="o">/></span> +</pre></div> +</div> +<p>Tokens may be either regenerated on every submission (default) or +kept the same throughout the life of the CSRF cookie. The default +regeneration of tokens provides stricter security, but may result +in usability concerns as other tokens become invalid (back/forward +navigation, multiple tabs/windows, asynchronous actions, etc). You +may alter this behavior by editing the following config parameter</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'csrf_regenerate'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +</pre></div> +</div> +<p>Select URIs can be whitelisted from csrf protection (for example API +endpoints expecting externally POSTed content). You can add these URIs +by editing the ‘csrf_exclude_uris’ config parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'csrf_exclude_uris'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'api/person/add'</span><span class="p">);</span> +</pre></div> +</div> +<p>Regular expressions are also supported (case-insensitive):</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'csrf_exclude_uris'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'api/record/[0-9]+'</span><span class="p">,</span> + <span class="s1">'api/title/[a-z]+'</span> +<span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id3">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Security"> +<em class="property">class </em><code class="descname">CI_Security</code><a class="headerlink" href="#CI_Security" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Security::xss_clean"> +<code class="descname">xss_clean</code><span class="sig-paren">(</span><em>$str</em><span class="optional">[</span>, <em>$is_image = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Security::xss_clean" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>mixed</em>) – Input string or an array of strings</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">XSS-clean data</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Tries to remove XSS exploits from the input data and returns the cleaned string. +If the optional second parameter is set to true, it will return boolean TRUE if +the image is safe to use and FALSE if malicious data was detected in it.</p> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">This method is not suitable for filtering HTML attribute values! +Use <a class="reference internal" href="../general/common_functions.html#html_escape" title="html_escape"><code class="xref php php-func docutils literal"><span class="pre">html_escape()</span></code></a> for that instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Security::sanitize_filename"> +<code class="descname">sanitize_filename</code><span class="sig-paren">(</span><em>$str</em><span class="optional">[</span>, <em>$relative_path = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Security::sanitize_filename" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – File name/path</li> +<li><strong>$relative_path</strong> (<em>bool</em>) – Whether to preserve any directories in the file path</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Sanitized file name/path</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Tries to sanitize filenames in order to prevent directory traversal attempts +and other security threats, which is particularly useful for files that were supplied via user input.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$filename</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">security</span><span class="o">-></span><span class="na">sanitize_filename</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="s1">'filename'</span><span class="p">));</span> +</pre></div> +</div> +<p>If it is acceptable for the user input to include relative paths, e.g. +<em>file/in/some/approved/folder.txt</em>, you can set the second optional parameter, <code class="docutils literal"><span class="pre">$relative_path</span></code> to TRUE.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$filename</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">security</span><span class="o">-></span><span class="na">sanitize_filename</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">post</span><span class="p">(</span><span class="s1">'filename'</span><span class="p">),</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Security::get_csrf_token_name"> +<code class="descname">get_csrf_token_name</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Security::get_csrf_token_name" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">CSRF token name</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns the CSRF token name (the <code class="docutils literal"><span class="pre">$config['csrf_token_name']</span></code> value).</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Security::get_csrf_hash"> +<code class="descname">get_csrf_hash</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Security::get_csrf_hash" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">CSRF hash</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns the CSRF hash value. Useful in combination with <code class="docutils literal"><span class="pre">get_csrf_token_name()</span></code> +for manually building forms or sending valid AJAX POST requests.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Security::entity_decode"> +<code class="descname">entity_decode</code><span class="sig-paren">(</span><em>$str</em><span class="optional">[</span>, <em>$charset = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Security::entity_decode" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +<li><strong>$charset</strong> (<em>string</em>) – Character set of the input string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Entity-decoded string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>This method acts a lot like PHP’s own native <code class="docutils literal"><span class="pre">html_entity_decode()</span></code> function in ENT_COMPAT mode, only +it tries to detect HTML entities that don’t end in a semicolon because some browsers allow that.</p> +<p>If the <code class="docutils literal"><span class="pre">$charset</span></code> parameter is left empty, then your configured <code class="docutils literal"><span class="pre">$config['charset']</span></code> value will be used.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Security::get_random_bytes"> +<code class="descname">get_random_bytes</code><span class="sig-paren">(</span><em>$length</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Security::get_random_bytes" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$length</strong> (<em>int</em>) – Output length</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A binary stream of random bytes or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>A convenience method for getting proper random bytes via <code class="docutils literal"><span class="pre">mcrypt_create_iv()</span></code>, +<code class="docutils literal"><span class="pre">/dev/urandom</span></code> or <code class="docutils literal"><span class="pre">openssl_random_pseudo_bytes()</span></code> (in that order), if one +of them is available.</p> +<p>Used for generating CSRF and XSS tokens.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The output is NOT guaranteed to be cryptographically secure, +just the best attempt at that.</p> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="sessions.html" class="btn btn-neutral float-right" title="Session Library">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="parser.html" class="btn btn-neutral" title="Template Parser Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html new file mode 100644 index 000000000..2681525f9 --- /dev/null +++ b/user_guide/libraries/sessions.html @@ -0,0 +1,1922 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Session Library — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="HTML Table Class" href="table.html"/> + <link rel="prev" title="Security Class" href="security.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Session Library</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="session-library"> +<h1>Session Library<a class="headerlink" href="#session-library" title="Permalink to this headline">¶</a></h1> +<p>The Session class permits you maintain a user’s “state” and track their +activity while they browse your site.</p> +<p>CodeIgniter comes with a few session storage drivers:</p> +<blockquote> +<div><ul class="simple"> +<li>files (default; file-system based)</li> +<li>database</li> +<li>redis</li> +<li>memcached</li> +</ul> +</div></blockquote> +<p>In addition, you may create your own, custom session drivers based on other +kinds of storage, while still taking advantage of the features of the +Session class.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-session-class" id="id3">Using the Session Class</a><ul> +<li><a class="reference internal" href="#initializing-a-session" id="id4">Initializing a Session</a></li> +<li><a class="reference internal" href="#how-do-sessions-work" id="id5">How do Sessions work?</a><ul> +<li><a class="reference internal" href="#a-note-about-concurrency" id="id6">A note about concurrency</a></li> +</ul> +</li> +<li><a class="reference internal" href="#what-is-session-data" id="id7">What is Session Data?</a></li> +<li><a class="reference internal" href="#retrieving-session-data" id="id8">Retrieving Session Data</a></li> +<li><a class="reference internal" href="#adding-session-data" id="id9">Adding Session Data</a></li> +<li><a class="reference internal" href="#removing-session-data" id="id10">Removing Session Data</a></li> +<li><a class="reference internal" href="#flashdata" id="id11">Flashdata</a></li> +<li><a class="reference internal" href="#tempdata" id="id12">Tempdata</a></li> +<li><a class="reference internal" href="#destroying-a-session" id="id13">Destroying a Session</a></li> +<li><a class="reference internal" href="#accessing-session-metadata" id="id14">Accessing session metadata</a></li> +<li><a class="reference internal" href="#session-preferences" id="id15">Session Preferences</a></li> +<li><a class="reference internal" href="#session-drivers" id="id16">Session Drivers</a><ul> +<li><a class="reference internal" href="#files-driver" id="id17">Files Driver</a><ul> +<li><a class="reference internal" href="#bonus-tip" id="id18">Bonus Tip</a></li> +</ul> +</li> +<li><a class="reference internal" href="#database-driver" id="id19">Database Driver</a></li> +<li><a class="reference internal" href="#redis-driver" id="id20">Redis Driver</a></li> +<li><a class="reference internal" href="#memcached-driver" id="id21">Memcached Driver</a><ul> +<li><a class="reference internal" href="#id1" id="id22">Bonus Tip</a></li> +</ul> +</li> +<li><a class="reference internal" href="#custom-drivers" id="id23">Custom Drivers</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id24">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-session-class"> +<h2><a class="toc-backref" href="#id3">Using the Session Class</a><a class="headerlink" href="#using-the-session-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-a-session"> +<h3><a class="toc-backref" href="#id4">Initializing a Session</a><a class="headerlink" href="#initializing-a-session" title="Permalink to this headline">¶</a></h3> +<p>Sessions will typically run globally with each page load, so the Session +class should either be initialized in your <a class="reference internal" href="../general/controllers.html"><span class="doc">controller</span></a> constructors, or it can be <a class="reference internal" href="../general/autoloader.html"><span class="doc">auto-loaded</span></a> by the system. +For the most part the session class will run unattended in the background, +so simply initializing the class will cause it to read, create, and update +sessions when necessary.</p> +<p>To initialize the Session class manually in your controller constructor, +use the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'session'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Sessions library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Because the <a class="reference internal" href="loader.html"><span class="doc">Loader Class</span></a> is instantiated +by CodeIgniter’s base controller, make sure to call +<code class="docutils literal"><span class="pre">parent::__construct()</span></code> before trying to load a library from +inside a controller constructor.</p> +</div> +</div> +<div class="section" id="how-do-sessions-work"> +<h3><a class="toc-backref" href="#id5">How do Sessions work?</a><a class="headerlink" href="#how-do-sessions-work" title="Permalink to this headline">¶</a></h3> +<p>When a page is loaded, the session class will check to see if valid +session cookie is sent by the user’s browser. If a sessions cookie does +<strong>not</strong> exist (or if it doesn’t match one stored on the server or has +expired) a new session will be created and saved.</p> +<p>If a valid session does exist, its information will be updated. With each +update, the session ID may be regenerated if configured to do so.</p> +<p>It’s important for you to understand that once initialized, the Session +class runs automatically. There is nothing you need to do to cause the +above behavior to happen. You can, as you’ll see below, work with session +data, but the process of reading, writing, and updating a session is +automatic.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Under CLI, the Session library will automatically halt itself, +as this is a concept based entirely on the HTTP protocol.</p> +</div> +<div class="section" id="a-note-about-concurrency"> +<h4><a class="toc-backref" href="#id6">A note about concurrency</a><a class="headerlink" href="#a-note-about-concurrency" title="Permalink to this headline">¶</a></h4> +<p>Unless you’re developing a website with heavy AJAX usage, you can skip this +section. If you are, however, and if you’re experiencing performance +issues, then this note is exactly what you’re looking for.</p> +<p>Sessions in previous versions of CodeIgniter didn’t implement locking, +which meant that two HTTP requests using the same session could run exactly +at the same time. To use a more appropriate technical term - requests were +non-blocking.</p> +<p>However, non-blocking requests in the context of sessions also means +unsafe, because modifications to session data (or session ID regeneration) +in one request can interfere with the execution of a second, concurrent +request. This detail was at the root of many issues and the main reason why +CodeIgniter 3.0 has a completely re-written Session library.</p> +<p>Why are we telling you this? Because it is likely that after trying to +find the reason for your performance issues, you may conclude that locking +is the issue and therefore look into how to remove the locks …</p> +<p>DO NOT DO THAT! Removing locks would be <strong>wrong</strong> and it will cause you +more problems!</p> +<p>Locking is not the issue, it is a solution. Your issue is that you still +have the session open, while you’ve already processed it and therefore no +longer need it. So, what you need is to close the session for the +current request after you no longer need it.</p> +<p>Long story short - call <code class="docutils literal"><span class="pre">session_write_close()</span></code> once you no longer need +anything to do with session variables.</p> +</div> +</div> +<div class="section" id="what-is-session-data"> +<h3><a class="toc-backref" href="#id7">What is Session Data?</a><a class="headerlink" href="#what-is-session-data" title="Permalink to this headline">¶</a></h3> +<p>Session data is simply an array associated with a particular session ID +(cookie).</p> +<p>If you’ve used sessions in PHP before, you should be familiar with PHP’s +<a class="reference external" href="http://php.net/manual/en/reserved.variables.session.php">$_SESSION superglobal</a> +(if not, please read the content on that link).</p> +<p>CodeIgniter gives access to its session data through the same means, as it +uses the session handlers’ mechanism provided by PHP. Using session data is +as simple as manipulating (read, set and unset values) the <code class="docutils literal"><span class="pre">$_SESSION</span></code> +array.</p> +<p>In addition, CodeIgniter also provides 2 special types of session data +that are further explained below: flashdata and tempdata.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In previous versions, regular session data in CodeIgniter was +referred to as ‘userdata’. Have this in mind if that term is used +elsewhere in the manual. Most of it is written to explain how +the custom ‘userdata’ methods work.</p> +</div> +</div> +<div class="section" id="retrieving-session-data"> +<h3><a class="toc-backref" href="#id8">Retrieving Session Data</a><a class="headerlink" href="#retrieving-session-data" title="Permalink to this headline">¶</a></h3> +<p>Any piece of information from the session array is available through the +<code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> +</pre></div> +</div> +<p>Or through the magic getter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">item</span> +</pre></div> +</div> +<p>And for backwards compatibility, through the <code class="docutils literal"><span class="pre">userdata()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">userdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where item is the array key corresponding to the item you wish to fetch. +For example, to assign a previously stored ‘name’ item to the <code class="docutils literal"><span class="pre">$name</span></code> +variable, you will do this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'name'</span><span class="p">];</span> + +<span class="c1">// or:</span> + +<span class="nv">$name</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">name</span> + +<span class="c1">// or:</span> + +<span class="nv">$name</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">userdata</span><span class="p">(</span><span class="s1">'name'</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The <code class="docutils literal"><span class="pre">userdata()</span></code> method returns NULL if the item you are trying +to access does not exist.</p> +</div> +<p>If you want to retrieve all of the existing userdata, you can simply +omit the item key (magic getter only works for properties):</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span> + +<span class="c1">// or:</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">userdata</span><span class="p">();</span> +</pre></div> +</div> +</div> +<div class="section" id="adding-session-data"> +<h3><a class="toc-backref" href="#id9">Adding Session Data</a><a class="headerlink" href="#adding-session-data" title="Permalink to this headline">¶</a></h3> +<p>Let’s say a particular user logs into your site. Once authenticated, you +could add their username and e-mail address to the session, making that +data globally available to you without having to run a database query when +you need it.</p> +<p>You can simply assign data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> array, as with any other +variable. Or as a property of <code class="docutils literal"><span class="pre">$this->session</span></code>.</p> +<p>Alternatively, the old method of assigning it as “userdata” is also +available. That however passing an array containing your new data to the +<code class="docutils literal"><span class="pre">set_userdata()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_userdata</span><span class="p">(</span><span class="nv">$array</span><span class="p">);</span> +</pre></div> +</div> +<p>Where <code class="docutils literal"><span class="pre">$array</span></code> is an associative array containing your new data. Here’s +an example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$newdata</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'username'</span> <span class="o">=></span> <span class="s1">'johndoe'</span><span class="p">,</span> + <span class="s1">'email'</span> <span class="o">=></span> <span class="s1">'johndoe@some-site.com'</span><span class="p">,</span> + <span class="s1">'logged_in'</span> <span class="o">=></span> <span class="k">TRUE</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_userdata</span><span class="p">(</span><span class="nv">$newdata</span><span class="p">);</span> +</pre></div> +</div> +<p>If you want to add userdata one value at a time, <code class="docutils literal"><span class="pre">set_userdata()</span></code> also +supports this syntax:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_userdata</span><span class="p">(</span><span class="s1">'some_name'</span><span class="p">,</span> <span class="s1">'some_value'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you want to verify that a session value exists, simply check with +<code class="docutils literal"><span class="pre">isset()</span></code>:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// returns FALSE if the 'some_name' item doesn't exist or is NULL,</span> +<span class="c1">// TRUE otherwise:</span> +<span class="nb">isset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'some_name'</span><span class="p">])</span> +</pre></div> +</div> +<p>Or you can call <code class="docutils literal"><span class="pre">has_userdata()</span></code>:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">has_userdata</span><span class="p">(</span><span class="s1">'some_name'</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="removing-session-data"> +<h3><a class="toc-backref" href="#id10">Removing Session Data</a><a class="headerlink" href="#removing-session-data" title="Permalink to this headline">¶</a></h3> +<p>Just as with any other variable, unsetting a value in <code class="docutils literal"><span class="pre">$_SESSION</span></code> can be +done through <code class="docutils literal"><span class="pre">unset()</span></code>:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">unset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'some_name'</span><span class="p">]);</span> + +<span class="c1">// or multiple values:</span> + +<span class="nb">unset</span><span class="p">(</span> + <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'some_name'</span><span class="p">],</span> + <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'another_name'</span><span class="p">]</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Also, just as <code class="docutils literal"><span class="pre">set_userdata()</span></code> can be used to add information to a +session, <code class="docutils literal"><span class="pre">unset_userdata()</span></code> can be used to remove it, by passing the +session key. For example, if you wanted to remove ‘some_name’ from your +session data array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">unset_userdata</span><span class="p">(</span><span class="s1">'some_name'</span><span class="p">);</span> +</pre></div> +</div> +<p>This method also accepts an array of item keys to unset:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$array_items</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'email'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">unset_userdata</span><span class="p">(</span><span class="nv">$array_items</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In previous versions, the <code class="docutils literal"><span class="pre">unset_userdata()</span></code> method used +to accept an associative array of <code class="docutils literal"><span class="pre">key</span> <span class="pre">=></span> <span class="pre">'dummy</span> <span class="pre">value'</span></code> +pairs. This is no longer supported.</p> +</div> +</div> +<div class="section" id="flashdata"> +<h3><a class="toc-backref" href="#id11">Flashdata</a><a class="headerlink" href="#flashdata" title="Permalink to this headline">¶</a></h3> +<p>CodeIgniter supports “flashdata”, or session data that will only be +available for the next request, and is then automatically cleared.</p> +<p>This can be very useful, especially for one-time informational, error or +status messages (for example: “Record 2 deleted”).</p> +<p>It should be noted that flashdata variables are regular session vars, +only marked in a specific way under the ‘__ci_vars’ key (please don’t touch +that one, you’ve been warned).</p> +<p>To mark an existing item as “flashdata”:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_flash</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you want to mark multiple items as flashdata, simply pass the keys as an +array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_flash</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'item2'</span><span class="p">));</span> +</pre></div> +</div> +<p>To add flashdata:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'value'</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_flash</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +</pre></div> +</div> +<p>Or alternatively, using the <code class="docutils literal"><span class="pre">set_flashdata()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_flashdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'value'</span><span class="p">);</span> +</pre></div> +</div> +<p>You can also pass an array to <code class="docutils literal"><span class="pre">set_flashdata()</span></code>, in the same manner as +<code class="docutils literal"><span class="pre">set_userdata()</span></code>.</p> +<p>Reading flashdata variables is the same as reading regular session data +through <code class="docutils literal"><span class="pre">$_SESSION</span></code>:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The <code class="docutils literal"><span class="pre">userdata()</span></code> method will NOT return flashdata items.</p> +</div> +<p>However, if you want to be sure that you’re reading “flashdata” (and not +any other kind), you can also use the <code class="docutils literal"><span class="pre">flashdata()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">flashdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +</pre></div> +</div> +<p>Or to get an array with all flashdata, simply omit the key parameter:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">flashdata</span><span class="p">();</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The <code class="docutils literal"><span class="pre">flashdata()</span></code> method returns NULL if the item cannot be +found.</p> +</div> +<p>If you find that you need to preserve a flashdata variable through an +additional request, you can do so using the <code class="docutils literal"><span class="pre">keep_flashdata()</span></code> method. +You can either pass a single item or an array of flashdata items to keep.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">keep_flashdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">keep_flashdata</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'item1'</span><span class="p">,</span> <span class="s1">'item2'</span><span class="p">,</span> <span class="s1">'item3'</span><span class="p">));</span> +</pre></div> +</div> +</div> +<div class="section" id="tempdata"> +<h3><a class="toc-backref" href="#id12">Tempdata</a><a class="headerlink" href="#tempdata" title="Permalink to this headline">¶</a></h3> +<p>CodeIgniter also supports “tempdata”, or session data with a specific +expiration time. After the value expires, or the session expires or is +deleted, the value is automatically removed.</p> +<p>Similarly to flashdata, tempdata variables are regular session vars that +are marked in a specific way under the ‘__ci_vars’ key (again, don’t touch +that one).</p> +<p>To mark an existing item as “tempdata”, simply pass its key and expiry time +(in seconds!) to the <code class="docutils literal"><span class="pre">mark_as_temp()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// 'item' will be erased after 300 seconds</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> +</pre></div> +</div> +<p>You can mark multiple items as tempdata in two ways, depending on whether +you want them all to have the same expiry time or not:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Both 'item' and 'item2' will expire after 300 seconds</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'item2'</span><span class="p">),</span> <span class="mi">300</span><span class="p">);</span> + +<span class="c1">// 'item' will be erased after 300 seconds, while 'item2'</span> +<span class="c1">// will do so after only 240 seconds</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="k">array</span><span class="p">(</span> + <span class="s1">'item'</span> <span class="o">=></span> <span class="mi">300</span><span class="p">,</span> + <span class="s1">'item2'</span> <span class="o">=></span> <span class="mi">240</span> +<span class="p">));</span> +</pre></div> +</div> +<p>To add tempdata:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'value'</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> <span class="c1">// Expire in 5 minutes</span> +</pre></div> +</div> +<p>Or alternatively, using the <code class="docutils literal"><span class="pre">set_tempdata()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_tempdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'value'</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> +</pre></div> +</div> +<p>You can also pass an array to <code class="docutils literal"><span class="pre">set_tempdata()</span></code>:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$tempdata</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'newuser'</span> <span class="o">=></span> <span class="k">TRUE</span><span class="p">,</span> <span class="s1">'message'</span> <span class="o">=></span> <span class="s1">'Thanks for joining!'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_tempdata</span><span class="p">(</span><span class="nv">$tempdata</span><span class="p">,</span> <span class="k">NULL</span><span class="p">,</span> <span class="nv">$expire</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If the expiration is omitted or set to 0, the default +time-to-live value of 300 seconds (or 5 minutes) will be used.</p> +</div> +<p>To read a tempdata variable, again you can just access it through the +<code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">The <code class="docutils literal"><span class="pre">userdata()</span></code> method will NOT return tempdata items.</p> +</div> +<p>Or if you want to be sure that you’re reading “tempdata” (and not any +other kind), you can also use the <code class="docutils literal"><span class="pre">tempdata()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">tempdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +</pre></div> +</div> +<p>And of course, if you want to retrieve all existing tempdata:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">tempdata</span><span class="p">();</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The <code class="docutils literal"><span class="pre">tempdata()</span></code> method returns NULL if the item cannot be +found.</p> +</div> +<p>If you need to remove a tempdata value before it expires, you can directly +unset it from the <code class="docutils literal"><span class="pre">$_SESSION</span></code> array:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">unset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]);</span> +</pre></div> +</div> +<p>However, this won’t remove the marker that makes this specific item to be +tempdata (it will be invalidated on the next HTTP request), so if you +intend to reuse that same key in the same request, you’d want to use +<code class="docutils literal"><span class="pre">unset_tempdata()</span></code>:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">unset_tempdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="destroying-a-session"> +<h3><a class="toc-backref" href="#id13">Destroying a Session</a><a class="headerlink" href="#destroying-a-session" title="Permalink to this headline">¶</a></h3> +<p>To clear the current session (for example, during a logout), you may +simply use either PHP’s <a class="reference external" href="http://php.net/session_destroy">session_destroy()</a> +function, or the <code class="docutils literal"><span class="pre">sess_destroy()</span></code> method. Both will work in exactly the +same way:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">session_destroy</span><span class="p">();</span> + +<span class="c1">// or</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">sess_destroy</span><span class="p">();</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This must be the last session-related operation that you do +during the same request. All session data (including flashdata and +tempdata) will be destroyed permanently and functions will be +unusable during the same request after you destroy the session.</p> +</div> +</div> +<div class="section" id="accessing-session-metadata"> +<h3><a class="toc-backref" href="#id14">Accessing session metadata</a><a class="headerlink" href="#accessing-session-metadata" title="Permalink to this headline">¶</a></h3> +<p>In previous CodeIgniter versions, the session data array included 4 items +by default: ‘session_id’, ‘ip_address’, ‘user_agent’, ‘last_activity’.</p> +<p>This was due to the specifics of how sessions worked, but is now no longer +necessary with our new implementation. However, it may happen that your +application relied on these values, so here are alternative methods of +accessing them:</p> +<blockquote> +<div><ul class="simple"> +<li>session_id: <code class="docutils literal"><span class="pre">session_id()</span></code></li> +<li>ip_address: <code class="docutils literal"><span class="pre">$_SERVER['REMOTE_ADDR']</span></code></li> +<li>user_agent: <code class="docutils literal"><span class="pre">$this->input->user_agent()</span></code> (unused by sessions)</li> +<li>last_activity: Depends on the storage, no straightforward way. Sorry!</li> +</ul> +</div></blockquote> +</div> +<div class="section" id="session-preferences"> +<h3><a class="toc-backref" href="#id15">Session Preferences</a><a class="headerlink" href="#session-preferences" title="Permalink to this headline">¶</a></h3> +<p>CodeIgniter will usually make everything work out of the box. However, +Sessions are a very sensitive component of any application, so some +careful configuration must be done. Please take your time to consider +all of the options and their effects.</p> +<p>You’ll find the following Session related preferences in your +<strong>application/config/config.php</strong> file:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="16%" /> +<col width="9%" /> +<col width="23%" /> +<col width="53%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default</th> +<th class="head">Options</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>sess_driver</strong></td> +<td>files</td> +<td>files/database/redis/memcached/<em>custom</em></td> +<td>The session storage driver to use.</td> +</tr> +<tr class="row-odd"><td><strong>sess_cookie_name</strong></td> +<td>ci_session</td> +<td>[A-Za-z_-] characters only</td> +<td>The name used for the session cookie.</td> +</tr> +<tr class="row-even"><td><strong>sess_expiration</strong></td> +<td>7200 (2 hours)</td> +<td>Time in seconds (integer)</td> +<td>The number of seconds you would like the session to last. +If you would like a non-expiring session (until browser is closed) set the value to zero: 0</td> +</tr> +<tr class="row-odd"><td><strong>sess_save_path</strong></td> +<td>NULL</td> +<td>None</td> +<td>Specifies the storage location, depends on the driver being used.</td> +</tr> +<tr class="row-even"><td><strong>sess_match_ip</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>Whether to validate the user’s IP address when reading the session cookie. +Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you +will likely set this to FALSE.</td> +</tr> +<tr class="row-odd"><td><strong>sess_time_to_update</strong></td> +<td>300</td> +<td>Time in seconds (integer)</td> +<td>This option controls how often the session class will regenerate itself and create a new +session ID. Setting it to 0 will disable session ID regeneration.</td> +</tr> +<tr class="row-even"><td><strong>sess_regenerate_destroy</strong></td> +<td>FALSE</td> +<td>TRUE/FALSE (boolean)</td> +<td>Whether to destroy session data associated with the old session ID when auto-regenerating +the session ID. When set to FALSE, the data will be later deleted by the garbage collector.</td> +</tr> +</tbody> +</table> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">As a last resort, the Session library will try to fetch PHP’s +session related INI settings, as well as legacy CI settings such as +‘sess_expire_on_close’ when any of the above is not configured. +However, you should never rely on this behavior as it can cause +unexpected results or be changed in the future. Please configure +everything properly.</p> +</div> +<p>In addition to the values above, the cookie and native drivers apply the +following configuration values shared by the <a class="reference internal" href="input.html"><span class="doc">Input</span></a> and +<a class="reference internal" href="security.html"><span class="doc">Security</span></a> classes:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="14%" /> +<col width="69%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Preference</th> +<th class="head">Default</th> +<th class="head">Description</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><strong>cookie_domain</strong></td> +<td>‘’</td> +<td>The domain for which the session is applicable</td> +</tr> +<tr class="row-odd"><td><strong>cookie_path</strong></td> +<td>/</td> +<td>The path to which the session is applicable</td> +</tr> +<tr class="row-even"><td><strong>cookie_secure</strong></td> +<td>FALSE</td> +<td>Whether to create the session cookie only on encrypted (HTTPS) connections</td> +</tr> +</tbody> +</table> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The ‘cookie_httponly’ setting doesn’t have an effect on sessions. +Instead the HttpOnly parameter is always enabled, for security +reasons. Additionally, the ‘cookie_prefix’ setting is completely +ignored.</p> +</div> +</div> +<div class="section" id="session-drivers"> +<h3><a class="toc-backref" href="#id16">Session Drivers</a><a class="headerlink" href="#session-drivers" title="Permalink to this headline">¶</a></h3> +<p>As already mentioned, the Session library comes with 4 drivers, or storage +engines, that you can use:</p> +<blockquote> +<div><ul class="simple"> +<li>files</li> +<li>database</li> +<li>redis</li> +<li>memcached</li> +</ul> +</div></blockquote> +<p>By default, the <a class="reference internal" href="#files-driver">Files Driver</a> will be used when a session is initialized, +because it is the most safe choice and is expected to work everywhere +(virtually every environment has a file system).</p> +<p>However, any other driver may be selected via the <code class="docutils literal"><span class="pre">$config['sess_driver']</span></code> +line in your <strong>application/config/config.php</strong> file, if you chose to do so. +Have it in mind though, every driver has different caveats, so be sure to +get yourself familiar with them (below) before you make that choice.</p> +<p>In addition, you may also create and use <a class="reference internal" href="#custom-drivers">Custom Drivers</a>, if the ones +provided by default don’t satisfy your use case.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In previous CodeIgniter versions, a different, “cookie driver” +was the only option and we have received negative feedback on not +providing that option. While we do listen to feedback from the +community, we want to warn you that it was dropped because it is +<strong>unsafe</strong> and we advise you NOT to try to replicate it via a +custom driver.</p> +</div> +<div class="section" id="files-driver"> +<h4><a class="toc-backref" href="#id17">Files Driver</a><a class="headerlink" href="#files-driver" title="Permalink to this headline">¶</a></h4> +<p>The ‘files’ driver uses your file system for storing session data.</p> +<p>It can safely be said that it works exactly like PHP’s own default session +implementation, but in case this is an important detail for you, have it +mind that it is in fact not the same code and it has some limitations +(and advantages).</p> +<p>To be more specific, it doesn’t support PHP’s <a class="reference external" href="http://php.net/manual/en/session.configuration.php#ini.session.save-path">directory level and mode +formats used in session.save_path</a>, +and it has most of the options hard-coded for safety. Instead, only +absolute paths are supported for <code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code>.</p> +<p>Another important thing that you should know, is to make sure that you +don’t use a publicly-readable or shared directory for storing your session +files. Make sure that <em>only you</em> have access to see the contents of your +chosen <em>sess_save_path</em> directory. Otherwise, anybody who can do that, can +also steal any of the current sessions (also known as “session fixation” +attack).</p> +<p>On UNIX-like operating systems, this is usually achieved by setting the +0700 mode permissions on that directory via the <cite>chmod</cite> command, which +allows only the directory’s owner to perform read and write operations on +it. But be careful because the system user <em>running</em> the script is usually +not your own, but something like ‘www-data’ instead, so only setting those +permissions will probable break your application.</p> +<p>Instead, you should do something like this, depending on your environment</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">mkdir</span> <span class="o">/<</span><span class="nx">path</span> <span class="nx">to</span> <span class="nx">your</span> <span class="nx">application</span> <span class="nx">directory</span><span class="o">>/</span><span class="nx">sessions</span><span class="o">/</span> +<span class="nb">chmod</span> <span class="mo">0700</span> <span class="o">/<</span><span class="nx">path</span> <span class="nx">to</span> <span class="nx">your</span> <span class="nx">application</span> <span class="nx">directory</span><span class="o">>/</span><span class="nx">sessions</span><span class="o">/</span> +<span class="nb">chown</span> <span class="nx">www</span><span class="o">-</span><span class="nx">data</span> <span class="o">/<</span><span class="nx">path</span> <span class="nx">to</span> <span class="nx">your</span> <span class="nx">application</span> <span class="nx">directory</span><span class="o">>/</span><span class="nx">sessions</span><span class="o">/</span> +</pre></div> +</div> +<div class="section" id="bonus-tip"> +<h5><a class="toc-backref" href="#id18">Bonus Tip</a><a class="headerlink" href="#bonus-tip" title="Permalink to this headline">¶</a></h5> +<p>Some of you will probably opt to choose another session driver because +file storage is usually slower. This is only half true.</p> +<p>A very basic test will probably trick you into believing that an SQL +database is faster, but in 99% of the cases, this is only true while you +only have a few current sessions. As the sessions count and server loads +increase - which is the time when it matters - the file system will +consistently outperform almost all relational database setups.</p> +<p>In addition, if performance is your only concern, you may want to look +into using <a class="reference external" href="http://eddmann.com/posts/storing-php-sessions-file-caches-in-memory-using-tmpfs/">tmpfs</a>, +(warning: external resource), which can make your sessions blazing fast.</p> +</div> +</div> +<div class="section" id="database-driver"> +<h4><a class="toc-backref" href="#id19">Database Driver</a><a class="headerlink" href="#database-driver" title="Permalink to this headline">¶</a></h4> +<p>The ‘database’ driver uses a relational database such as MySQL or +PostgreSQL to store sessions. This is a popular choice among many users, +because it allows the developer easy access to the session data within +an application - it is just another table in your database.</p> +<p>However, there are some conditions that must be met:</p> +<blockquote> +<div><ul class="simple"> +<li>Only your <strong>default</strong> database connection (or the one that you access +as <code class="docutils literal"><span class="pre">$this->db</span></code> from your controllers) can be used.</li> +<li>You must have the <a class="reference internal" href="../database/query_builder.html"><span class="doc">Query Builder</span></a> +enabled.</li> +<li>You can NOT use a persistent connection.</li> +<li>You can NOT use a connection with the <em>cache_on</em> setting enabled.</li> +</ul> +</div></blockquote> +<p>In order to use the ‘database’ session driver, you must also create this +table that we already mentioned and then set it as your +<code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code> value. +For example, if you would like to use ‘ci_sessions’ as your table name, +you would do this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_driver'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'database'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ci_sessions'</span><span class="p">;</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">If you’ve upgraded from a previous version of CodeIgniter and +you don’t have ‘sess_save_path’ configured, then the Session +library will look for the old ‘sess_table_name’ setting and use +it instead. Please don’t rely on this behavior as it will get +removed in the future.</p> +</div> +<p>And then of course, create the database table …</p> +<p>For MySQL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CREATE</span> <span class="nx">TABLE</span> <span class="k">IF</span> <span class="k">NOT</span> <span class="nx">EXISTS</span> <span class="sb">`ci_sessions`</span> <span class="p">(</span> + <span class="sb">`id`</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="sb">`ip_address`</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="sb">`timestamp`</span> <span class="nx">int</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="nx">unsigned</span> <span class="k">DEFAULT</span> <span class="mi">0</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="sb">`data`</span> <span class="nx">blob</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">KEY</span> <span class="sb">`ci_sessions_timestamp`</span> <span class="p">(</span><span class="sb">`timestamp`</span><span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>For PostgreSQL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CREATE</span> <span class="nx">TABLE</span> <span class="s2">"ci_sessions"</span> <span class="p">(</span> + <span class="s2">"id"</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="s2">"ip_address"</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="s2">"timestamp"</span> <span class="nx">bigint</span> <span class="k">DEFAULT</span> <span class="mi">0</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="s2">"data"</span> <span class="nx">text</span> <span class="k">DEFAULT</span> <span class="s1">''</span> <span class="k">NOT</span> <span class="k">NULL</span> +<span class="p">);</span> + +<span class="nx">CREATE</span> <span class="nx">INDEX</span> <span class="s2">"ci_sessions_timestamp"</span> <span class="nx">ON</span> <span class="s2">"ci_sessions"</span> <span class="p">(</span><span class="s2">"timestamp"</span><span class="p">);</span> +</pre></div> +</div> +<p>You will also need to add a PRIMARY KEY <strong>depending on your ‘sess_match_ip’ +setting</strong>. The examples below work both on MySQL and PostgreSQL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// When sess_match_ip = TRUE</span> +<span class="nx">ALTER</span> <span class="nx">TABLE</span> <span class="nx">ci_sessions</span> <span class="nx">ADD</span> <span class="nx">PRIMARY</span> <span class="nx">KEY</span> <span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">ip_address</span><span class="p">);</span> + +<span class="c1">// When sess_match_ip = FALSE</span> +<span class="nx">ALTER</span> <span class="nx">TABLE</span> <span class="nx">ci_sessions</span> <span class="nx">ADD</span> <span class="nx">PRIMARY</span> <span class="nx">KEY</span> <span class="p">(</span><span class="nx">id</span><span class="p">);</span> + +<span class="c1">// To drop a previously created primary key (use when changing the setting)</span> +<span class="nx">ALTER</span> <span class="nx">TABLE</span> <span class="nx">ci_sessions</span> <span class="nx">DROP</span> <span class="nx">PRIMARY</span> <span class="nx">KEY</span><span class="p">;</span> +</pre></div> +</div> +<div class="admonition important"> +<p class="first admonition-title">Important</p> +<p class="last">Only MySQL and PostgreSQL databases are officially +supported, due to lack of advisory locking mechanisms on other +platforms. Using sessions without locks can cause all sorts of +problems, especially with heavy usage of AJAX, and we will not +support such cases. Use <code class="docutils literal"><span class="pre">session_write_close()</span></code> after you’ve +done processing session data if you’re having performance +issues.</p> +</div> +</div> +<div class="section" id="redis-driver"> +<h4><a class="toc-backref" href="#id20">Redis Driver</a><a class="headerlink" href="#redis-driver" title="Permalink to this headline">¶</a></h4> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Since Redis doesn’t have a locking mechanism exposed, locks for +this driver are emulated by a separate value that is kept for up +to 300 seconds.</p> +</div> +<p>Redis is a storage engine typically used for caching and popular because +of its high performance, which is also probably your reason to use the +‘redis’ session driver.</p> +<p>The downside is that it is not as ubiquitous as relational databases and +requires the <a class="reference external" href="https://github.com/phpredis/phpredis">phpredis</a> PHP +extension to be installed on your system, and that one doesn’t come +bundled with PHP. +Chances are, you’re only be using the ‘redis’ driver only if you’re already +both familiar with Redis and using it for other purposes.</p> +<p>Just as with the ‘files’ and ‘database’ drivers, you must also configure +the storage location for your sessions via the +<code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code> setting. +The format here is a bit different and complicated at the same time. It is +best explained by the <em>phpredis</em> extension’s README file, so we’ll simply +link you to it:</p> +<blockquote> +<div><a class="reference external" href="https://github.com/phpredis/phpredis#php-session-handler">https://github.com/phpredis/phpredis#php-session-handler</a></div></blockquote> +<div class="admonition warning"> +<p class="first admonition-title">Warning</p> +<p class="last">CodeIgniter’s Session library does NOT use the actual ‘redis’ +<code class="docutils literal"><span class="pre">session.save_handler</span></code>. Take note <strong>only</strong> of the path format in +the link above.</p> +</div> +<p>For the most common case however, a simple <code class="docutils literal"><span class="pre">host:port</span></code> pair should be +sufficient:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_driver'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'redis'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'tcp://localhost:6379'</span><span class="p">;</span> +</pre></div> +</div> +</div> +<div class="section" id="memcached-driver"> +<h4><a class="toc-backref" href="#id21">Memcached Driver</a><a class="headerlink" href="#memcached-driver" title="Permalink to this headline">¶</a></h4> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Since Memcache doesn’t have a locking mechanism exposed, locks +for this driver are emulated by a separate value that is kept for +up to 300 seconds.</p> +</div> +<p>The ‘memcached’ driver is very similar to the ‘redis’ one in all of its +properties, except perhaps for availability, because PHP’s <a class="reference external" href="http://php.net/memcached">Memcached</a> extension is distributed via PECL and some +Linux distrubutions make it available as an easy to install package.</p> +<p>Other than that, and without any intentional bias towards Redis, there’s +not much different to be said about Memcached - it is also a popular +product that is usually used for caching and famed for its speed.</p> +<p>However, it is worth noting that the only guarantee given by Memcached +is that setting value X to expire after Y seconds will result in it being +deleted after Y seconds have passed (but not necessarily that it won’t +expire earlier than that time). This happens very rarely, but should be +considered as it may result in loss of sessions.</p> +<p>The <code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code> format is fairly straightforward here, +being just a <code class="docutils literal"><span class="pre">host:port</span></code> pair:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_driver'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'memcached'</span><span class="p">;</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'localhost:11211'</span><span class="p">;</span> +</pre></div> +</div> +<div class="section" id="id1"> +<h5><a class="toc-backref" href="#id22">Bonus Tip</a><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h5> +<p>Multi-server configuration with an optional <em>weight</em> parameter as the +third colon-separated (<code class="docutils literal"><span class="pre">:weight</span></code>) value is also supported, but we have +to note that we haven’t tested if that is reliable.</p> +<p>If you want to experiment with this feature (on your own risk), simply +separate the multiple server paths with commas:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// localhost will be given higher priority (5) here,</span> +<span class="c1">// compared to 192.0.2.1 with a weight of 1.</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'localhost:11211:5,192.0.2.1:11211:1'</span><span class="p">;</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="custom-drivers"> +<h4><a class="toc-backref" href="#id23">Custom Drivers</a><a class="headerlink" href="#custom-drivers" title="Permalink to this headline">¶</a></h4> +<p>You may also create your own, custom session drivers. However, have it in +mind that this is typically not an easy task, as it takes a lot of +knowledge to do it properly.</p> +<p>You need to know not only how sessions work in general, but also how they +work specifically in PHP, how the underlying storage mechanism works, how +to handle concurrency, avoid deadlocks (but NOT through lack of locks) and +last but not least - how to handle the potential security issues, which +is far from trivial.</p> +<p>Long story short - if you don’t know how to do that already in raw PHP, +you shouldn’t be trying to do it within CodeIgniter either. You’ve been +warned.</p> +<p>If you only want to add some extra functionality to your sessions, just +extend the base Session class, which is a lot more easier. Read the +<a class="reference internal" href="../general/creating_libraries.html"><span class="doc">Creating Libraries</span></a> article to +learn how to do that.</p> +<p>Now, to the point - there are three general rules that you must follow +when creating a session driver for CodeIgniter:</p> +<blockquote> +<div><ul> +<li><p class="first">Put your driver’s file under <strong>application/libraries/Session/drivers/</strong> +and follow the naming conventions used by the Session class.</p> +<p>For example, if you were to create a ‘dummy’ driver, you would have +a <code class="docutils literal"><span class="pre">Session_dummy_driver</span></code> class name, that is declared in +<em>application/libraries/Session/drivers/Session_dummy_driver.php</em>.</p> +</li> +<li><p class="first">Extend the <code class="docutils literal"><span class="pre">CI_Session_driver</span></code> class.</p> +<p>This is just a basic class with a few internal helper methods. It is +also extendable like any other library, if you really need to do that, +but we are not going to explain how … if you’re familiar with how +class extensions/overrides work in CI, then you already know how to do +it. If not, well, you shouldn’t be doing it in the first place.</p> +</li> +<li><p class="first">Implement the <a class="reference external" href="http://php.net/sessionhandlerinterface">SessionHandlerInterface</a> interface.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You may notice that <code class="docutils literal"><span class="pre">SessionHandlerInterface</span></code> is provided +by PHP since version 5.4.0. CodeIgniter will automatically declare +the same interface if you’re running an older PHP version.</p> +</div> +<p>The link will explain why and how.</p> +</li> +</ul> +</div></blockquote> +<p>So, based on our ‘dummy’ driver example above, you’d end up with something +like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// application/libraries/Session/drivers/Session_dummy_driver.php:</span> + +<span class="k">class</span> <span class="nc">CI_Session_dummy_driver</span> <span class="k">extends</span> <span class="nx">CI_Session_driver</span> <span class="k">implements</span> <span class="nx">SessionHandlerInterface</span> +<span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">__construct</span><span class="p">(</span><span class="o">&</span><span class="nv">$params</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// DO NOT forget this</span> + <span class="k">parent</span><span class="o">::</span><span class="na">__construct</span><span class="p">(</span><span class="nv">$params</span><span class="p">);</span> + + <span class="c1">// Configuration & other initializations</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">open</span><span class="p">(</span><span class="nv">$save_path</span><span class="p">,</span> <span class="nv">$name</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Initialize storage mechanism (connection)</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">read</span><span class="p">(</span><span class="nv">$session_id</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Read session data (if exists), acquire locks</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">write</span><span class="p">(</span><span class="nv">$session_id</span><span class="p">,</span> <span class="nv">$session_data</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Create / update session data (it might not exist!)</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">close</span><span class="p">()</span> + <span class="p">{</span> + <span class="c1">// Free locks, close connections / streams / etc.</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">destroy</span><span class="p">(</span><span class="nv">$session_id</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Call close() method & destroy data for current session (order may differ)</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">gc</span><span class="p">(</span><span class="nv">$maxlifetime</span><span class="p">)</span> + <span class="p">{</span> + <span class="c1">// Erase data for expired sessions</span> + <span class="p">}</span> + +<span class="p">}</span> +</pre></div> +</div> +<p>If you’ve done everything properly, you can now set your <em>sess_driver</em> +configuration value to ‘dummy’ and use your own driver. Congratulations!</p> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id24">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Session"> +<em class="property">class </em><code class="descname">CI_Session</code><a class="headerlink" href="#CI_Session" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Session::userdata"> +<code class="descname">userdata</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::userdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Session item key or NULL</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the specified item key, or an array of all userdata</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Gets the value for a specific <code class="docutils literal"><span class="pre">$_SESSION</span></code> item, or an +array of all “userdata” items if not key was specified.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications. You should +directly access <code class="docutils literal"><span class="pre">$_SESSION</span></code> instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::all_userdata"> +<code class="descname">all_userdata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::all_userdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array of all userdata</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Returns an array containing all “userdata” items.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is DEPRECATED. Use <code class="docutils literal"><span class="pre">userdata()</span></code> +with no parameters instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt> +<code class="descname">&get_userdata()</code></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A reference to <code class="docutils literal"><span class="pre">$_SESSION</span></code></td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Returns a reference to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> array.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::has_userdata"> +<code class="descname">has_userdata</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::has_userdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Session item key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the specified key exists, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Checks if an item exists in <code class="docutils literal"><span class="pre">$_SESSION</span></code>.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications. It is just +an alias for <code class="docutils literal"><span class="pre">isset($_SESSION[$key])</span></code> - please +use that instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::set_userdata"> +<code class="descname">set_userdata</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::set_userdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>mixed</em>) – An array of key/value pairs to set as session data, or the key for a single item</li> +<li><strong>$value</strong> (<em>mixed</em>) – The value to set for a specific session item, if $data is a key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Assigns data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::unset_userdata"> +<code class="descname">unset_userdata</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::unset_userdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Key for the session data item to unset, or an array of multiple keys</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Unsets the specified key(s) from the <code class="docutils literal"><span class="pre">$_SESSION</span></code> +superglobal.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications. It is just +an alias for <code class="docutils literal"><span class="pre">unset($_SESSION[$key])</span></code> - please +use that instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::mark_as_flash"> +<code class="descname">mark_as_flash</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::mark_as_flash" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Key to mark as flashdata, or an array of multiple keys</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Marks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as +“flashdata”.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::get_flash_keys"> +<code class="descname">get_flash_keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::get_flash_keys" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing the keys of all “flashdata” items.</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Gets a list of all <code class="docutils literal"><span class="pre">$_SESSION</span></code> that have been marked as +“flashdata”.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::unmark_flash"> +<code class="descname">unmark_flash</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::unmark_flash" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Key to be un-marked as flashdata, or an array of multiple keys</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Unmarks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as +“flashdata”.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::flashdata"> +<code class="descname">flashdata</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::flashdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Flashdata item key or NULL</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the specified item key, or an array of all flashdata</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Gets the value for a specific <code class="docutils literal"><span class="pre">$_SESSION</span></code> item that has +been marked as “flashdata”, or an array of all “flashdata” +items if no key was specified.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications. You should +directly access <code class="docutils literal"><span class="pre">$_SESSION</span></code> instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::keep_flashdata"> +<code class="descname">keep_flashdata</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::keep_flashdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Flashdata key to keep, or an array of multiple keys</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Retains the specified session data key(s) as “flashdata” +through the next request.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications. It is just +an alias for the <code class="docutils literal"><span class="pre">mark_as_flash()</span></code> method.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::set_flashdata"> +<code class="descname">set_flashdata</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::set_flashdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>mixed</em>) – An array of key/value pairs to set as flashdata, or the key for a single item</li> +<li><strong>$value</strong> (<em>mixed</em>) – The value to set for a specific session item, if $data is a key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Assigns data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal and marks it +as “flashdata”.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::mark_as_temp"> +<code class="descname">mark_as_temp</code><span class="sig-paren">(</span><em>$key</em><span class="optional">[</span>, <em>$ttl = 300</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::mark_as_temp" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Key to mark as tempdata, or an array of multiple keys</li> +<li><strong>$ttl</strong> (<em>int</em>) – Time-to-live value for the tempdata, in seconds</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Marks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as +“tempdata”.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::get_temp_keys"> +<code class="descname">get_temp_keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::get_temp_keys" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing the keys of all “tempdata” items.</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Gets a list of all <code class="docutils literal"><span class="pre">$_SESSION</span></code> that have been marked as +“tempdata”.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::unmark_temp"> +<code class="descname">unmark_temp</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::unmark_temp" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Key to be un-marked as tempdata, or an array of multiple keys</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Unmarks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as +“tempdata”.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::tempdata"> +<code class="descname">tempdata</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::tempdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>mixed</em>) – Tempdata item key or NULL</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the specified item key, or an array of all tempdata</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Gets the value for a specific <code class="docutils literal"><span class="pre">$_SESSION</span></code> item that has +been marked as “tempdata”, or an array of all “tempdata” +items if no key was specified.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications. You should +directly access <code class="docutils literal"><span class="pre">$_SESSION</span></code> instead.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::set_tempdata"> +<code class="descname">set_tempdata</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::set_tempdata" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$data</strong> (<em>mixed</em>) – An array of key/value pairs to set as tempdata, or the key for a single item</li> +<li><strong>$value</strong> (<em>mixed</em>) – The value to set for a specific session item, if $data is a key</li> +<li><strong>$ttl</strong> (<em>int</em>) – Time-to-live value for the tempdata item(s), in seconds</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Assigns data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal and marks it +as “tempdata”.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is a legacy method kept only for backwards +compatibility with older applications.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::sess_regenerate"> +<code class="descname">sess_regenerate</code><span class="sig-paren">(</span><span class="optional">[</span><em>$destroy = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::sess_regenerate" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$destroy</strong> (<em>bool</em>) – Whether to destroy session data</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Regenerate session ID, optionally destroying the current +session’s data.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is just an alias for PHP’s native +<a class="reference external" href="http://php.net/session_regenerate_id">session_regenerate_id()</a> function.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::sess_destroy"> +<code class="descname">sess_destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::sess_destroy" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> +</tr> +</tbody> +</table> +<p>Destroys the current session.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This must be the <em>last</em> session-related function +that you call. All session data will be lost after +you do that.</p> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is just an alias for PHP’s native +<a class="reference external" href="http://php.net/session_destroy">session_destroy()</a> function.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::__get"> +<code class="descname">__get</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::__get" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Session item key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The requested session data item, or NULL if it doesn’t exist</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>A magic method that allows you to use +<code class="docutils literal"><span class="pre">$this->session->item</span></code> instead of <code class="docutils literal"><span class="pre">$_SESSION['item']</span></code>, +if that’s what you prefer.</p> +<p>It will also return the session ID by calling +<code class="docutils literal"><span class="pre">session_id()</span></code> if you try to access +<code class="docutils literal"><span class="pre">$this->session->session_id</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Session::__set"> +<code class="descname">__set</code><span class="sig-paren">(</span><em>$key</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::__set" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Session item key</li> +<li><strong>$value</strong> (<em>mixed</em>) – Value to assign to the session item key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>A magic method that allows you to assign items to +<code class="docutils literal"><span class="pre">$_SESSION</span></code> by accessing them as <code class="docutils literal"><span class="pre">$this->session</span></code> +properties:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">foo</span> <span class="o">=</span> <span class="s1">'bar'</span><span class="p">;</span> + +<span class="c1">// Results in:</span> +<span class="c1">// $_SESSION['foo'] = 'bar';</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="table.html" class="btn btn-neutral float-right" title="HTML Table Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="security.html" class="btn btn-neutral" title="Security Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html new file mode 100644 index 000000000..ad812a3bc --- /dev/null +++ b/user_guide/libraries/table.html @@ -0,0 +1,911 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>HTML Table Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Trackback Class" href="trackback.html"/> + <link rel="prev" title="Session Library" href="sessions.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>HTML Table Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="html-table-class"> +<h1>HTML Table Class<a class="headerlink" href="#html-table-class" title="Permalink to this headline">¶</a></h1> +<p>The Table Class provides functions that enable you to auto-generate HTML +tables from arrays or database result sets.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-table-class" id="id1">Using the Table Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#examples" id="id3">Examples</a></li> +<li><a class="reference internal" href="#changing-the-look-of-your-table" id="id4">Changing the Look of Your Table</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id5">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-table-class"> +<h2><a class="toc-backref" href="#id1">Using the Table Class</a><a class="headerlink" href="#using-the-table-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Table class is initialized +in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Table library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">table</span> +</pre></div> +</div> +</div> +<div class="section" id="examples"> +<h3><a class="toc-backref" href="#id3">Examples</a><a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3> +<p>Here is an example showing how you can create a table from a +multi-dimensional array. Note that the first array index will become the +table heading (or you can set your own headings using the <code class="docutils literal"><span class="pre">set_heading()</span></code> +method described in the function reference below).</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'Fred'</span><span class="p">,</span> <span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'Small'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'Mary'</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Large'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">,</span> <span class="s1">'Medium'</span><span class="p">)</span> +<span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>Here is an example of a table created from a database query result. The +table class will automatically generate the headings based on the table +names (or you can set your own headings using the <code class="docutils literal"><span class="pre">set_heading()</span></code> +method described in the class reference below).</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> + +<span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">db</span><span class="o">-></span><span class="na">query</span><span class="p">(</span><span class="s1">'SELECT * FROM my_table'</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">(</span><span class="nv">$query</span><span class="p">);</span> +</pre></div> +</div> +<p>Here is an example showing how you might create a table using discrete +parameters:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Fred'</span><span class="p">,</span> <span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'Small'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Mary'</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Large'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">,</span> <span class="s1">'Medium'</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +<p>Here is the same example, except instead of individual parameters, +arrays are used:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">));</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'Fred'</span><span class="p">,</span> <span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'Small'</span><span class="p">));</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'Mary'</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Large'</span><span class="p">));</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">,</span> <span class="s1">'Medium'</span><span class="p">));</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +</div> +<div class="section" id="changing-the-look-of-your-table"> +<h3><a class="toc-backref" href="#id4">Changing the Look of Your Table</a><a class="headerlink" href="#changing-the-look-of-your-table" title="Permalink to this headline">¶</a></h3> +<p>The Table Class permits you to set a table template with which you can +specify the design of your layout. Here is the template prototype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'table_open'</span> <span class="o">=></span> <span class="s1">'<table border="0" cellpadding="4" cellspacing="0">'</span><span class="p">,</span> + + <span class="s1">'thead_open'</span> <span class="o">=></span> <span class="s1">'<thead>'</span><span class="p">,</span> + <span class="s1">'thead_close'</span> <span class="o">=></span> <span class="s1">'</thead>'</span><span class="p">,</span> + + <span class="s1">'heading_row_start'</span> <span class="o">=></span> <span class="s1">'<tr>'</span><span class="p">,</span> + <span class="s1">'heading_row_end'</span> <span class="o">=></span> <span class="s1">'</tr>'</span><span class="p">,</span> + <span class="s1">'heading_cell_start'</span> <span class="o">=></span> <span class="s1">'<th>'</span><span class="p">,</span> + <span class="s1">'heading_cell_end'</span> <span class="o">=></span> <span class="s1">'</th>'</span><span class="p">,</span> + + <span class="s1">'tbody_open'</span> <span class="o">=></span> <span class="s1">'<tbody>'</span><span class="p">,</span> + <span class="s1">'tbody_close'</span> <span class="o">=></span> <span class="s1">'</tbody>'</span><span class="p">,</span> + + <span class="s1">'row_start'</span> <span class="o">=></span> <span class="s1">'<tr>'</span><span class="p">,</span> + <span class="s1">'row_end'</span> <span class="o">=></span> <span class="s1">'</tr>'</span><span class="p">,</span> + <span class="s1">'cell_start'</span> <span class="o">=></span> <span class="s1">'<td>'</span><span class="p">,</span> + <span class="s1">'cell_end'</span> <span class="o">=></span> <span class="s1">'</td>'</span><span class="p">,</span> + + <span class="s1">'row_alt_start'</span> <span class="o">=></span> <span class="s1">'<tr>'</span><span class="p">,</span> + <span class="s1">'row_alt_end'</span> <span class="o">=></span> <span class="s1">'</tr>'</span><span class="p">,</span> + <span class="s1">'cell_alt_start'</span> <span class="o">=></span> <span class="s1">'<td>'</span><span class="p">,</span> + <span class="s1">'cell_alt_end'</span> <span class="o">=></span> <span class="s1">'</td>'</span><span class="p">,</span> + + <span class="s1">'table_close'</span> <span class="o">=></span> <span class="s1">'</table>'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_template</span><span class="p">(</span><span class="nv">$template</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">You’ll notice there are two sets of “row” blocks in the +template. These permit you to create alternating row colors or design +elements that alternate with each iteration of the row data.</p> +</div> +<p>You are NOT required to submit a complete template. If you only need to +change parts of the layout you can simply submit those elements. In this +example, only the table opening tag is being changed:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'table_open'</span> <span class="o">=></span> <span class="s1">'<table border="1" cellpadding="2" cellspacing="1" class="mytable">'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_template</span><span class="p">(</span><span class="nv">$template</span><span class="p">);</span> +</pre></div> +</div> +<p>You can also set defaults for these in a config file.</p> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id5">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Table"> +<em class="property">class </em><code class="descname">CI_Table</code><a class="headerlink" href="#CI_Table" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$function = NULL</code></dt> +<dd><p>Allows you to specify a native PHP function or a valid function array object to be applied to all cell data.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Fred'</span><span class="p">,</span> <span class="s1">'<strong>Blue</strong>'</span><span class="p">,</span> <span class="s1">'Small'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">function</span> <span class="o">=</span> <span class="s1">'htmlspecialchars'</span><span class="p">;</span> +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +<p>In the above example, all cell data would be ran through PHP’s <code class="xref php php-func docutils literal"><span class="pre">htmlspecialchars()</span></code> function, resulting in:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">td</span><span class="o">></span><span class="nx">Fred</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">>&</span><span class="nx">lt</span><span class="p">;</span><span class="nx">strong</span><span class="o">&</span><span class="nx">gt</span><span class="p">;</span><span class="nx">Blue</span><span class="o">&</span><span class="nx">lt</span><span class="p">;</span><span class="o">/</span><span class="nx">strong</span><span class="o">&</span><span class="nx">gt</span><span class="p">;</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">Small</span><span class="o"></</span><span class="nx">td</span><span class="o">></span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::generate"> +<code class="descname">generate</code><span class="sig-paren">(</span><span class="optional">[</span><em>$table_data = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::generate" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$table_data</strong> (<em>mixed</em>) – Data to populate the table rows with</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML table</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the generated table. Accepts an optional parameter which can be an array or a database result object.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::set_caption"> +<code class="descname">set_caption</code><span class="sig-paren">(</span><em>$caption</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::set_caption" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$caption</strong> (<em>string</em>) – Table caption</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Table instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Table</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to add a caption to the table.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_caption</span><span class="p">(</span><span class="s1">'Colors'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::set_heading"> +<code class="descname">set_heading</code><span class="sig-paren">(</span><span class="optional">[</span><em>$args = array()</em><span class="optional">[</span>, <em>...</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::set_heading" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$args</strong> (<em>mixed</em>) – An array or multiple strings containing the table column titles</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Table instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Table</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set the table heading. You can submit an array or discrete params:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">));</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::add_row"> +<code class="descname">add_row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$args = array()</em><span class="optional">[</span>, <em>...</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::add_row" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$args</strong> (<em>mixed</em>) – An array or multiple strings containing the row values</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Table instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Table</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to add a row to your table. You can submit an array or discrete params:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">));</span> +</pre></div> +</div> +<p>If you would like to set an individual cell’s tag attributes, you can use an associative array for that cell. +The associative key <strong>data</strong> defines the cell’s data. Any other key => val pairs are added as key=’val’ attributes to the tag:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$cell</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'data'</span> <span class="o">=></span> <span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'class'</span> <span class="o">=></span> <span class="s1">'highlight'</span><span class="p">,</span> <span class="s1">'colspan'</span> <span class="o">=></span> <span class="mi">2</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="nv">$cell</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">);</span> + +<span class="c1">// generates</span> +<span class="c1">// <td class='highlight' colspan='2'>Blue</td><td>Red</td><td>Green</td></span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::make_columns"> +<code class="descname">make_columns</code><span class="sig-paren">(</span><span class="optional">[</span><em>$array = array()</em><span class="optional">[</span>, <em>$col_limit = 0</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::make_columns" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$array</strong> (<em>array</em>) – An array containing multiple rows’ data</li> +<li><strong>$col_limit</strong> (<em>int</em>) – Count of columns in the table</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An array of HTML table columns</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>This method takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns desired. +This allows a single array with many elements to be displayed in a table that has a fixed column count. Consider this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$list</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'one'</span><span class="p">,</span> <span class="s1">'two'</span><span class="p">,</span> <span class="s1">'three'</span><span class="p">,</span> <span class="s1">'four'</span><span class="p">,</span> <span class="s1">'five'</span><span class="p">,</span> <span class="s1">'six'</span><span class="p">,</span> <span class="s1">'seven'</span><span class="p">,</span> <span class="s1">'eight'</span><span class="p">,</span> <span class="s1">'nine'</span><span class="p">,</span> <span class="s1">'ten'</span><span class="p">,</span> <span class="s1">'eleven'</span><span class="p">,</span> <span class="s1">'twelve'</span><span class="p">);</span> + +<span class="nv">$new_list</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">make_columns</span><span class="p">(</span><span class="nv">$list</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">(</span><span class="nv">$new_list</span><span class="p">);</span> + +<span class="c1">// Generates a table with this prototype</span> + +<span class="o"><</span><span class="nx">table</span> <span class="nx">border</span><span class="o">=</span><span class="s2">"0"</span> <span class="nx">cellpadding</span><span class="o">=</span><span class="s2">"4"</span> <span class="nx">cellspacing</span><span class="o">=</span><span class="s2">"0"</span><span class="o">></span> +<span class="o"><</span><span class="nx">tr</span><span class="o">></span> +<span class="o"><</span><span class="nx">td</span><span class="o">></span><span class="nx">one</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">two</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">three</span><span class="o"></</span><span class="nx">td</span><span class="o">></span> +<span class="o"></</span><span class="nx">tr</span><span class="o">><</span><span class="nx">tr</span><span class="o">></span> +<span class="o"><</span><span class="nx">td</span><span class="o">></span><span class="nx">four</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">five</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">six</span><span class="o"></</span><span class="nx">td</span><span class="o">></span> +<span class="o"></</span><span class="nx">tr</span><span class="o">><</span><span class="nx">tr</span><span class="o">></span> +<span class="o"><</span><span class="nx">td</span><span class="o">></span><span class="nx">seven</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">eight</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">nine</span><span class="o"></</span><span class="nx">td</span><span class="o">></span> +<span class="o"></</span><span class="nx">tr</span><span class="o">><</span><span class="nx">tr</span><span class="o">></span> +<span class="o"><</span><span class="nx">td</span><span class="o">></span><span class="nx">ten</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">eleven</span><span class="o"></</span><span class="nx">td</span><span class="o">><</span><span class="nx">td</span><span class="o">></span><span class="nx">twelve</span><span class="o"></</span><span class="nx">td</span><span class="o">></</span><span class="nx">tr</span><span class="o">></span> +<span class="o"></</span><span class="nx">table</span><span class="o">></span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::set_template"> +<code class="descname">set_template</code><span class="sig-paren">(</span><em>$template</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::set_template" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$template</strong> (<em>array</em>) – An associative array containing template values</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to set your template. You can submit a full or partial template.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$template</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'table_open'</span> <span class="o">=></span> <span class="s1">'<table border="1" cellpadding="2" cellspacing="1" class="mytable">'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_template</span><span class="p">(</span><span class="nv">$template</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::set_empty"> +<code class="descname">set_empty</code><span class="sig-paren">(</span><em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::set_empty" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$value</strong> (<em>mixed</em>) – Value to put in empty cells</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">CI_Table instance (method chaining)</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CI_Table</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you set a default value for use in any table cells that are empty. +You might, for example, set a non-breaking space:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_empty</span><span class="p">(</span><span class="s2">"&nbsp;"</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Table::clear"> +<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Table::clear" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">CI_Table instance (method chaining)</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">CI_Table</td> +</tr> +</tbody> +</table> +<p>Lets you clear the table heading and row data. If you need to show multiple tables with different data you should to call this method +after each table has been generated to clear the previous table information. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'table'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Color'</span><span class="p">,</span> <span class="s1">'Size'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Fred'</span><span class="p">,</span> <span class="s1">'Blue'</span><span class="p">,</span> <span class="s1">'Small'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Mary'</span><span class="p">,</span> <span class="s1">'Red'</span><span class="p">,</span> <span class="s1">'Large'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'Green'</span><span class="p">,</span> <span class="s1">'Medium'</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">clear</span><span class="p">();</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">set_heading</span><span class="p">(</span><span class="s1">'Name'</span><span class="p">,</span> <span class="s1">'Day'</span><span class="p">,</span> <span class="s1">'Delivery'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Fred'</span><span class="p">,</span> <span class="s1">'Wednesday'</span><span class="p">,</span> <span class="s1">'Express'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'Mary'</span><span class="p">,</span> <span class="s1">'Monday'</span><span class="p">,</span> <span class="s1">'Air'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">add_row</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'Saturday'</span><span class="p">,</span> <span class="s1">'Overnight'</span><span class="p">);</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">table</span><span class="o">-></span><span class="na">generate</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="trackback.html" class="btn btn-neutral float-right" title="Trackback Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="sessions.html" class="btn btn-neutral" title="Session Library"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html new file mode 100644 index 000000000..62ed1d0bc --- /dev/null +++ b/user_guide/libraries/trackback.html @@ -0,0 +1,1035 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Trackback Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Typography Class" href="typography.html"/> + <link rel="prev" title="HTML Table Class" href="table.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Trackback Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="trackback-class"> +<h1>Trackback Class<a class="headerlink" href="#trackback-class" title="Permalink to this headline">¶</a></h1> +<p>The Trackback Class provides functions that enable you to send and +receive Trackback data.</p> +<p>If you are not familiar with Trackbacks you’ll find more information +<a class="reference external" href="http://en.wikipedia.org/wiki/Trackback">here</a>.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-trackback-class" id="id1">Using the Trackback Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#sending-trackbacks" id="id3">Sending Trackbacks</a></li> +<li><a class="reference internal" href="#receiving-trackbacks" id="id4">Receiving Trackbacks</a></li> +<li><a class="reference internal" href="#your-ping-url" id="id5">Your Ping URL</a></li> +<li><a class="reference internal" href="#creating-a-trackback-table" id="id6">Creating a Trackback Table</a></li> +<li><a class="reference internal" href="#processing-a-trackback" id="id7">Processing a Trackback</a><ul> +<li><a class="reference internal" href="#notes" id="id8">Notes:</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id9">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-trackback-class"> +<h2><a class="toc-backref" href="#id1">Using the Trackback Class</a><a class="headerlink" href="#using-the-trackback-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Trackback class is +initialized in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'trackback'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Trackback library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span> +</pre></div> +</div> +</div> +<div class="section" id="sending-trackbacks"> +<h3><a class="toc-backref" href="#id3">Sending Trackbacks</a><a class="headerlink" href="#sending-trackbacks" title="Permalink to this headline">¶</a></h3> +<p>A Trackback can be sent from any of your controller functions using code +similar to this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'trackback'</span><span class="p">);</span> + +<span class="nv">$tb_data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'ping_url'</span> <span class="o">=></span> <span class="s1">'http://example.com/trackback/456'</span><span class="p">,</span> + <span class="s1">'url'</span> <span class="o">=></span> <span class="s1">'http://www.my-example.com/blog/entry/123'</span><span class="p">,</span> + <span class="s1">'title'</span> <span class="o">=></span> <span class="s1">'The Title of My Entry'</span><span class="p">,</span> + <span class="s1">'excerpt'</span> <span class="o">=></span> <span class="s1">'The entry content.'</span><span class="p">,</span> + <span class="s1">'blog_name'</span> <span class="o">=></span> <span class="s1">'My Blog Name'</span><span class="p">,</span> + <span class="s1">'charset'</span> <span class="o">=></span> <span class="s1">'utf-8'</span> +<span class="p">);</span> + +<span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">send</span><span class="p">(</span><span class="nv">$tb_data</span><span class="p">))</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +<span class="p">}</span> +<span class="k">else</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'Trackback was sent!'</span><span class="p">;</span> +<span class="p">}</span> +</pre></div> +</div> +<p>Description of array data:</p> +<ul class="simple"> +<li><strong>ping_url</strong> - The URL of the site you are sending the Trackback to. +You can send Trackbacks to multiple URLs by separating each URL with a comma.</li> +<li><strong>url</strong> - The URL to YOUR site where the weblog entry can be seen.</li> +<li><strong>title</strong> - The title of your weblog entry.</li> +<li><strong>excerpt</strong> - The content of your weblog entry.</li> +<li><strong>blog_name</strong> - The name of your weblog.</li> +<li><strong>charset</strong> - The character encoding your weblog is written in. If omitted, UTF-8 will be used.</li> +</ul> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The Trackback class will automatically send only the first 500 characters of your +entry. It will also strip all HTML.</p> +</div> +<p>The Trackback sending method returns TRUE/FALSE (boolean) on success +or failure. If it fails, you can retrieve the error message using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> +</pre></div> +</div> +</div> +<div class="section" id="receiving-trackbacks"> +<h3><a class="toc-backref" href="#id4">Receiving Trackbacks</a><a class="headerlink" href="#receiving-trackbacks" title="Permalink to this headline">¶</a></h3> +<p>Before you can receive Trackbacks you must create a weblog. If you don’t +have a blog yet there’s no point in continuing.</p> +<p>Receiving Trackbacks is a little more complex than sending them, only +because you will need a database table in which to store them, and you +will need to validate the incoming trackback data. You are encouraged to +implement a thorough validation process to guard against spam and +duplicate data. You may also want to limit the number of Trackbacks you +allow from a particular IP within a given span of time to further +curtail spam. The process of receiving a Trackback is quite simple; the +validation is what takes most of the effort.</p> +</div> +<div class="section" id="your-ping-url"> +<h3><a class="toc-backref" href="#id5">Your Ping URL</a><a class="headerlink" href="#your-ping-url" title="Permalink to this headline">¶</a></h3> +<p>In order to accept Trackbacks you must display a Trackback URL next to +each one of your weblog entries. This will be the URL that people will +use to send you Trackbacks (we will refer to this as your “Ping URL”).</p> +<p>Your Ping URL must point to a controller function where your Trackback +receiving code is located, and the URL must contain the ID number for +each particular entry, so that when the Trackback is received you’ll be +able to associate it with a particular entry.</p> +<p>For example, if your controller class is called Trackback, and the +receiving function is called receive, your Ping URLs will look something +like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">trackback</span><span class="o">/</span><span class="nx">receive</span><span class="o">/</span><span class="nx">entry_id</span> +</pre></div> +</div> +<p>Where entry_id represents the individual ID number for each of your +entries.</p> +</div> +<div class="section" id="creating-a-trackback-table"> +<h3><a class="toc-backref" href="#id6">Creating a Trackback Table</a><a class="headerlink" href="#creating-a-trackback-table" title="Permalink to this headline">¶</a></h3> +<p>Before you can receive Trackbacks you must create a table in which to +store them. Here is a basic prototype for such a table:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CREATE</span> <span class="nx">TABLE</span> <span class="nx">trackbacks</span> <span class="p">(</span> + <span class="nx">tb_id</span> <span class="nx">int</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="nx">unsigned</span> <span class="k">NOT</span> <span class="k">NULL</span> <span class="nx">auto_increment</span><span class="p">,</span> + <span class="nx">entry_id</span> <span class="nx">int</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="nx">unsigned</span> <span class="k">NOT</span> <span class="k">NULL</span> <span class="k">default</span> <span class="mi">0</span><span class="p">,</span> + <span class="nx">url</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">title</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">excerpt</span> <span class="nx">text</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">blog_name</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">tb_date</span> <span class="nx">int</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">ip_address</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> + <span class="nx">PRIMARY</span> <span class="nx">KEY</span> <span class="sb">`tb_id`</span> <span class="p">(</span><span class="sb">`tb_id`</span><span class="p">),</span> + <span class="nx">KEY</span> <span class="sb">`entry_id`</span> <span class="p">(</span><span class="sb">`entry_id`</span><span class="p">)</span> +<span class="p">);</span> +</pre></div> +</div> +<p>The Trackback specification only requires four pieces of information to +be sent in a Trackback (url, title, excerpt, blog_name), but to make +the data more useful we’ve added a few more fields in the above table +schema (date, IP address, etc.).</p> +</div> +<div class="section" id="processing-a-trackback"> +<h3><a class="toc-backref" href="#id7">Processing a Trackback</a><a class="headerlink" href="#processing-a-trackback" title="Permalink to this headline">¶</a></h3> +<p>Here is an example showing how you will receive and process a Trackback. +The following code is intended for use within the controller function +where you expect to receive Trackbacks.:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'trackback'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">database</span><span class="p">();</span> + +<span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">==</span> <span class="k">FALSE</span><span class="p">)</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">send_error</span><span class="p">(</span><span class="s1">'Unable to determine the entry ID'</span><span class="p">);</span> +<span class="p">}</span> + +<span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">receive</span><span class="p">())</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">send_error</span><span class="p">(</span><span class="s1">'The Trackback did not contain valid data'</span><span class="p">);</span> +<span class="p">}</span> + +<span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'tb_id'</span> <span class="o">=></span> <span class="s1">''</span><span class="p">,</span> + <span class="s1">'entry_id'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> + <span class="s1">'url'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">data</span><span class="p">(</span><span class="s1">'url'</span><span class="p">),</span> + <span class="s1">'title'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">data</span><span class="p">(</span><span class="s1">'title'</span><span class="p">),</span> + <span class="s1">'excerpt'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">data</span><span class="p">(</span><span class="s1">'excerpt'</span><span class="p">),</span> + <span class="s1">'blog_name'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">data</span><span class="p">(</span><span class="s1">'blog_name'</span><span class="p">),</span> + <span class="s1">'tb_date'</span> <span class="o">=></span> <span class="nb">time</span><span class="p">(),</span> + <span class="s1">'ip_address'</span> <span class="o">=></span> <span class="nv">$this</span><span class="o">-></span><span class="na">input</span><span class="o">-></span><span class="na">ip_address</span><span class="p">()</span> +<span class="p">);</span> + +<span class="nv">$sql</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">db</span><span class="o">-></span><span class="na">insert_string</span><span class="p">(</span><span class="s1">'trackbacks'</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">db</span><span class="o">-></span><span class="na">query</span><span class="p">(</span><span class="nv">$sql</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">send_success</span><span class="p">();</span> +</pre></div> +</div> +<div class="section" id="notes"> +<h4><a class="toc-backref" href="#id8">Notes:</a><a class="headerlink" href="#notes" title="Permalink to this headline">¶</a></h4> +<p>The entry ID number is expected in the third segment of your URL. This +is based on the URI example we gave earlier:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">trackback</span><span class="o">/</span><span class="nx">receive</span><span class="o">/</span><span class="nx">entry_id</span> +</pre></div> +</div> +<p>Notice the entry_id is in the third URI segment, which you can retrieve +using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span> +</pre></div> +</div> +<p>In our Trackback receiving code above, if the third segment is missing, +we will issue an error. Without a valid entry ID, there’s no reason to +continue.</p> +<p>The $this->trackback->receive() function is simply a validation function +that looks at the incoming data and makes sure it contains the four +pieces of data that are required (url, title, excerpt, blog_name). It +returns TRUE on success and FALSE on failure. If it fails you will issue +an error message.</p> +<p>The incoming Trackback data can be retrieved using this function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">data</span><span class="p">(</span><span class="s1">'item'</span><span class="p">)</span> +</pre></div> +</div> +<p>Where item represents one of these four pieces of info: url, title, +excerpt, or blog_name</p> +<p>If the Trackback data is successfully received, you will issue a success +message using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">trackback</span><span class="o">-></span><span class="na">send_success</span><span class="p">();</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The above code contains no data validation, which you are +encouraged to add.</p> +</div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id9">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Trackback"> +<em class="property">class </em><code class="descname">CI_Trackback</code><a class="headerlink" href="#CI_Trackback" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '')</code></dt> +<dd><p>Trackback data array.</p> +</dd></dl> + +<dl class="attribute"> +<dt> +<code class="descname">$convert_ascii = TRUE</code></dt> +<dd><p>Whether to convert high ASCII and MS Word characters to HTML entities.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::send"> +<code class="descname">send</code><span class="sig-paren">(</span><em>$tb_data</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::send" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$tb_data</strong> (<em>array</em>) – Trackback data</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Send trackback.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::receive"> +<code class="descname">receive</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::receive" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>This method simply validates the incoming TB data, returning TRUE on success and FALSE on failure. +If the data is valid it is set to the <code class="docutils literal"><span class="pre">$this->data</span></code> array so that it can be inserted into a database.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::send_error"> +<code class="descname">send_error</code><span class="sig-paren">(</span><span class="optional">[</span><em>$message = 'Incomplete information'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::send_error" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$message</strong> (<em>string</em>) – Error message</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Responses to a trackback request with an error message.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method will terminate script execution.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::send_success"> +<code class="descname">send_success</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::send_success" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> +</tr> +</tbody> +</table> +<p>Responses to a trackback request with a success message.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method will terminate script execution.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::data"> +<code class="descname">data</code><span class="sig-paren">(</span><em>$item</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::data" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$item</strong> (<em>string</em>) – Data key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Data value or empty string if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns a single item from the response data array.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::process"> +<code class="descname">process</code><span class="sig-paren">(</span><em>$url</em>, <em>$data</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::process" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$url</strong> (<em>string</em>) – Target url</li> +<li><strong>$data</strong> (<em>string</em>) – Raw POST data</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Opens a socket connection and passes the data to the server, returning TRUE on success and FALSE on failure.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::extract_urls"> +<code class="descname">extract_urls</code><span class="sig-paren">(</span><em>$urls</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::extract_urls" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$urls</strong> (<em>string</em>) – Comma-separated URL list</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of URLs</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>This method lets multiple trackbacks to be sent. It takes a string of URLs (separated by comma or space) and puts each URL into an array.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::validate_url"> +<code class="descname">validate_url</code><span class="sig-paren">(</span><em>&$url</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::validate_url" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$url</strong> (<em>string</em>) – Trackback URL</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Simply adds the <em>http://</em> prefix it it’s not already present in the URL.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::get_id"> +<code class="descname">get_id</code><span class="sig-paren">(</span><em>$url</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::get_id" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$url</strong> (<em>string</em>) – Trackback URL</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">URL ID or FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Find and return a trackback URL’s ID or FALSE on failure.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::convert_xml"> +<code class="descname">convert_xml</code><span class="sig-paren">(</span><em>$str</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::convert_xml" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Converted string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Converts reserved XML characters to entities.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::limit_characters"> +<code class="descname">limit_characters</code><span class="sig-paren">(</span><em>$str</em><span class="optional">[</span>, <em>$n = 500</em><span class="optional">[</span>, <em>$end_char = '&#8230;'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::limit_characters" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +<li><strong>$n</strong> (<em>int</em>) – Max characters number</li> +<li><strong>$end_char</strong> (<em>string</em>) – Character to put at end of string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Shortened string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Limits the string based on the character count. Will preserve complete words.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::convert_ascii"> +<code class="descname">convert_ascii</code><span class="sig-paren">(</span><em>$str</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::convert_ascii" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Converted string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Converts high ASCII text and MS Word special characterss to HTML entities.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::set_error"> +<code class="descname">set_error</code><span class="sig-paren">(</span><em>$msg</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::set_error" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$msg</strong> (<em>string</em>) – Error message</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Set an log an error message.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Trackback::display_errors"> +<code class="descname">display_errors</code><span class="sig-paren">(</span><span class="optional">[</span><em>$open = '<p>'</em><span class="optional">[</span>, <em>$close = '</p>'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Trackback::display_errors" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$open</strong> (<em>string</em>) – Open tag</li> +<li><strong>$close</strong> (<em>string</em>) – Close tag</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML formatted error messages</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Returns error messages formatted in HTML or an empty string if there are no errors.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="typography.html" class="btn btn-neutral float-right" title="Typography Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="table.html" class="btn btn-neutral" title="HTML Table Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/typography.html b/user_guide/libraries/typography.html new file mode 100644 index 000000000..e183cfb4d --- /dev/null +++ b/user_guide/libraries/typography.html @@ -0,0 +1,657 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Typography Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Unit Testing Class" href="unit_testing.html"/> + <link rel="prev" title="Trackback Class" href="trackback.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Typography Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="typography-class"> +<h1>Typography Class<a class="headerlink" href="#typography-class" title="Permalink to this headline">¶</a></h1> +<p>The Typography Class provides methods that help you format text.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-typography-class" id="id1">Using the Typography Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id3">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-typography-class"> +<h2><a class="toc-backref" href="#id1">Using the Typography Class</a><a class="headerlink" href="#using-the-typography-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Typography class is +initialized in your controller using the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'typography'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Typography library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">typography</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id3">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Typography"> +<em class="property">class </em><code class="descname">CI_Typography</code><a class="headerlink" href="#CI_Typography" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$protect_braced_quotes = FALSE</code></dt> +<dd><p>When using the Typography library in conjunction with the <a class="reference internal" href="parser.html"><span class="doc">Template Parser library</span></a> +it can often be desirable to protect single and double quotes within curly braces. +To enable this, set the <code class="docutils literal"><span class="pre">protect_braced_quotes</span></code> class property to TRUE.</p> +<p>Usage example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'typography'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">typography</span><span class="o">-></span><span class="na">protect_braced_quotes</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Typography::auto_typography"> +<code class="descname">auto_typography</code><span class="sig-paren">(</span><em>$str</em><span class="optional">[</span>, <em>$reduce_linebreaks = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Typography::auto_typography" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +<li><strong>$reduce_linebreaks</strong> (<em>bool</em>) – Whether to reduce consecutive linebreaks</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML typography-safe string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Formats text so that it is semantically and typographically correct HTML. +Takes a string as input and returns it with the following formatting:</p> +<blockquote> +<div><ul class="simple"> +<li>Surrounds paragraphs within <p></p> (looks for double line breaks to identify paragraphs).</li> +<li>Single line breaks are converted to <br />, except those that appear within <pre> tags.</li> +<li>Block level elements, like <div> tags, are not wrapped within paragraphs, but their contained text is if it contains paragraphs.</li> +<li>Quotes are converted to correctly facing curly quote entities, except those that appear within tags.</li> +<li>Apostrophes are converted to curly apostrophe entities.</li> +<li>Double dashes (either like – this or like–this) are converted to em—dashes.</li> +<li>Three consecutive periods either preceding or following a word are converted to ellipsis (…).</li> +<li>Double spaces following sentences are converted to non-breaking spaces to mimic double spacing.</li> +</ul> +</div></blockquote> +<p>Usage example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">typography</span><span class="o">-></span><span class="na">auto_typography</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span> +</pre></div> +</div> +<p>There is one optional parameter that determines whether the parser should reduce more than two consecutive line breaks down to two. +Pass boolean TRUE to enable reducing line breaks:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">typography</span><span class="o">-></span><span class="na">auto_typography</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted. +If you choose to use this method you may want to consider <a class="reference internal" href="../general/caching.html"><span class="doc">caching</span></a> your pages.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Typography::format_characters"> +<code class="descname">format_characters</code><span class="sig-paren">(</span><em>$str</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Typography::format_characters" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Formatted string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>This method is similar to <code class="docutils literal"><span class="pre">auto_typography()</span></code> above, except that it only does character conversion:</p> +<blockquote> +<div><ul class="simple"> +<li>Quotes are converted to correctly facing curly quote entities, except those that appear within tags.</li> +<li>Apostrophes are converted to curly apostrophe entities.</li> +<li>Double dashes (either like – this or like–this) are converted to em—dashes.</li> +<li>Three consecutive periods either preceding or following a word are converted to ellipsis (…).</li> +<li>Double spaces following sentences are converted to non-breaking spaces to mimic double spacing.</li> +</ul> +</div></blockquote> +<p>Usage example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">typography</span><span class="o">-></span><span class="na">format_characters</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Typography::nl2br_except_pre"> +<code class="descname">nl2br_except_pre</code><span class="sig-paren">(</span><em>$str</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Typography::nl2br_except_pre" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$str</strong> (<em>string</em>) – Input string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Formatted string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Converts newlines to <br /> tags unless they appear within <pre> tags. +This method is identical to the native PHP <code class="xref php php-func docutils literal"><span class="pre">nl2br()</span></code> function, except that it ignores <pre> tags.</p> +<p>Usage example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">typography</span><span class="o">-></span><span class="na">nl2br_except_pre</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="unit_testing.html" class="btn btn-neutral float-right" title="Unit Testing Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="trackback.html" class="btn btn-neutral" title="Trackback Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/unit_testing.html b/user_guide/libraries/unit_testing.html new file mode 100644 index 000000000..0f543b7db --- /dev/null +++ b/user_guide/libraries/unit_testing.html @@ -0,0 +1,846 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Unit Testing Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="URI Class" href="uri.html"/> + <link rel="prev" title="Typography Class" href="typography.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Unit Testing Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="unit-testing-class"> +<h1>Unit Testing Class<a class="headerlink" href="#unit-testing-class" title="Permalink to this headline">¶</a></h1> +<p>Unit testing is an approach to software development in which tests are +written for each function in your application. If you are not familiar +with the concept you might do a little googling on the subject.</p> +<p>CodeIgniter’s Unit Test class is quite simple, consisting of an +evaluation function and two result functions. It’s not intended to be a +full-blown test suite but rather a simple mechanism to evaluate your +code to determine if it is producing the correct data type and result.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-unit-testing-library" id="id1">Using the Unit Testing Library</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#running-tests" id="id3">Running Tests</a></li> +<li><a class="reference internal" href="#generating-reports" id="id4">Generating Reports</a></li> +<li><a class="reference internal" href="#strict-mode" id="id5">Strict Mode</a></li> +<li><a class="reference internal" href="#enabling-disabling-unit-testing" id="id6">Enabling/Disabling Unit Testing</a></li> +<li><a class="reference internal" href="#unit-test-display" id="id7">Unit Test Display</a><ul> +<li><a class="reference internal" href="#customizing-displayed-tests" id="id8">Customizing displayed tests</a></li> +<li><a class="reference internal" href="#creating-a-template" id="id9">Creating a Template</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id10">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-unit-testing-library"> +<h2><a class="toc-backref" href="#id1">Using the Unit Testing Library</a><a class="headerlink" href="#using-the-unit-testing-library" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Unit Test class is +initialized in your controller using the $this->load->library function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'unit_test'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Unit Test object will be available using <code class="docutils literal"><span class="pre">$this->unit</span></code></p> +</div> +<div class="section" id="running-tests"> +<h3><a class="toc-backref" href="#id3">Running Tests</a><a class="headerlink" href="#running-tests" title="Permalink to this headline">¶</a></h3> +<p>Running a test involves supplying a test and an expected result in the +following way:</p> +<blockquote> +<div>$this->unit->run(‘test’, ‘expected result’, ‘test name’, ‘notes’);</div></blockquote> +<p>Where test is the result of the code you wish to test, expected result +is the data type you expect, test name is an optional name you can give +your test, and notes are optional notes. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$test</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span> + +<span class="nv">$expected_result</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span> + +<span class="nv">$test_name</span> <span class="o">=</span> <span class="s1">'Adds one plus one'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">run</span><span class="p">(</span><span class="nv">$test</span><span class="p">,</span> <span class="nv">$expected_result</span><span class="p">,</span> <span class="nv">$test_name</span><span class="p">);</span> +</pre></div> +</div> +<p>The expected result you supply can either be a literal match, or a data +type match. Here’s an example of a literal:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">run</span><span class="p">(</span><span class="s1">'Foo'</span><span class="p">,</span> <span class="s1">'Foo'</span><span class="p">);</span> +</pre></div> +</div> +<p>Here is an example of a data type match:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">run</span><span class="p">(</span><span class="s1">'Foo'</span><span class="p">,</span> <span class="s1">'is_string'</span><span class="p">);</span> +</pre></div> +</div> +<p>Notice the use of “is_string” in the second parameter? This tells the +function to evaluate whether your test is producing a string as the +result. Here is a list of allowed comparison types:</p> +<ul class="simple"> +<li>is_object</li> +<li>is_string</li> +<li>is_bool</li> +<li>is_true</li> +<li>is_false</li> +<li>is_int</li> +<li>is_numeric</li> +<li>is_float</li> +<li>is_double</li> +<li>is_array</li> +<li>is_null</li> +<li>is_resource</li> +</ul> +</div> +<div class="section" id="generating-reports"> +<h3><a class="toc-backref" href="#id4">Generating Reports</a><a class="headerlink" href="#generating-reports" title="Permalink to this headline">¶</a></h3> +<p>You can either display results after each test, or your can run several +tests and generate a report at the end. To show a report directly simply +echo or return the run function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">run</span><span class="p">(</span><span class="nv">$test</span><span class="p">,</span> <span class="nv">$expected_result</span><span class="p">);</span> +</pre></div> +</div> +<p>To run a full report of all tests, use this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">report</span><span class="p">();</span> +</pre></div> +</div> +<p>The report will be formatted in an HTML table for viewing. If you prefer +the raw data you can retrieve an array using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">result</span><span class="p">();</span> +</pre></div> +</div> +</div> +<div class="section" id="strict-mode"> +<h3><a class="toc-backref" href="#id5">Strict Mode</a><a class="headerlink" href="#strict-mode" title="Permalink to this headline">¶</a></h3> +<p>By default the unit test class evaluates literal matches loosely. +Consider this example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">run</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +<p>The test is evaluating an integer, but the expected result is a boolean. +PHP, however, due to it’s loose data-typing will evaluate the above code +as TRUE using a normal equality test:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="mi">1</span> <span class="o">==</span> <span class="k">TRUE</span><span class="p">)</span> <span class="k">echo</span> <span class="s1">'This evaluates as true'</span><span class="p">;</span> +</pre></div> +</div> +<p>If you prefer, you can put the unit test class in to strict mode, which +will compare the data type as well as the value:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="mi">1</span> <span class="o">===</span> <span class="k">TRUE</span><span class="p">)</span> <span class="k">echo</span> <span class="s1">'This evaluates as FALSE'</span><span class="p">;</span> +</pre></div> +</div> +<p>To enable strict mode use this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">use_strict</span><span class="p">(</span><span class="k">TRUE</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="enabling-disabling-unit-testing"> +<h3><a class="toc-backref" href="#id6">Enabling/Disabling Unit Testing</a><a class="headerlink" href="#enabling-disabling-unit-testing" title="Permalink to this headline">¶</a></h3> +<p>If you would like to leave some testing in place in your scripts, but +not have it run unless you need it, you can disable unit testing using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">active</span><span class="p">(</span><span class="k">FALSE</span><span class="p">);</span> +</pre></div> +</div> +</div> +<div class="section" id="unit-test-display"> +<h3><a class="toc-backref" href="#id7">Unit Test Display</a><a class="headerlink" href="#unit-test-display" title="Permalink to this headline">¶</a></h3> +<p>When your unit test results display, the following items show by +default:</p> +<ul class="simple"> +<li>Test Name (test_name)</li> +<li>Test Datatype (test_datatype)</li> +<li>Expected Datatype (res_datatype)</li> +<li>Result (result)</li> +<li>File Name (file)</li> +<li>Line Number (line)</li> +<li>Any notes you entered for the test (notes)</li> +</ul> +<p>You can customize which of these items get displayed by using +$this->unit->set_test_items(). For example, if you only wanted the test name +and the result displayed:</p> +<div class="section" id="customizing-displayed-tests"> +<h4><a class="toc-backref" href="#id8">Customizing displayed tests</a><a class="headerlink" href="#customizing-displayed-tests" title="Permalink to this headline">¶</a></h4> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">set_test_items</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'test_name'</span><span class="p">,</span> <span class="s1">'result'</span><span class="p">));</span> +</pre></div> +</div> +</div> +<div class="section" id="creating-a-template"> +<h4><a class="toc-backref" href="#id9">Creating a Template</a><a class="headerlink" href="#creating-a-template" title="Permalink to this headline">¶</a></h4> +<p>If you would like your test results formatted differently then the +default you can set your own template. Here is an example of a simple +template. Note the required pseudo-variables:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$str</span> <span class="o">=</span> <span class="s1">'</span> +<span class="s1"><table border="0" cellpadding="4" cellspacing="1"></span> +<span class="s1">{rows}</span> +<span class="s1"> <tr></span> +<span class="s1"> <td>{item}</td></span> +<span class="s1"> <td>{result}</td></span> +<span class="s1"> </tr></span> +<span class="s1">{/rows}</span> +<span class="s1"></table>'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">unit</span><span class="o">-></span><span class="na">set_template</span><span class="p">(</span><span class="nv">$str</span><span class="p">);</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Your template must be declared <strong>before</strong> running the unit +test process.</p> +</div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id10">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Unit_test"> +<em class="property">class </em><code class="descname">CI_Unit_test</code><a class="headerlink" href="#CI_Unit_test" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Unit_test::set_test_items"> +<code class="descname">set_test_items</code><span class="sig-paren">(</span><em>$items</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::set_test_items" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$items</strong> (<em>array</em>) – List of visible test items</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets a list of items that should be visible in tests. +Valid options are:</p> +<blockquote> +<div><ul class="simple"> +<li>test_name</li> +<li>test_datatype</li> +<li>res_datatype</li> +<li>result</li> +<li>file</li> +<li>line</li> +<li>notes</li> +</ul> +</div></blockquote> +</dd></dl> + +<dl class="method"> +<dt id="CI_Unit_test::run"> +<code class="descname">run</code><span class="sig-paren">(</span><em>$test</em><span class="optional">[</span>, <em>$expected = TRUE</em><span class="optional">[</span>, <em>$test_name = 'undefined'</em><span class="optional">[</span>, <em>$notes = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::run" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$test</strong> (<em>mixed</em>) – Test data</li> +<li><strong>$expected</strong> (<em>mixed</em>) – Expected result</li> +<li><strong>$test_name</strong> (<em>string</em>) – Test name</li> +<li><strong>$notes</strong> (<em>string</em>) – Any notes to be attached to the test</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Test report</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Runs unit tests.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Unit_test::report"> +<code class="descname">report</code><span class="sig-paren">(</span><span class="optional">[</span><em>$result = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::report" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$result</strong> (<em>array</em>) – Array containing tests results</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Test report</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Generates a report about already complete tests.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Unit_test::use_strict"> +<code class="descname">use_strict</code><span class="sig-paren">(</span><span class="optional">[</span><em>$state = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::use_strict" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$state</strong> (<em>bool</em>) – Strict state flag</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Enables/disables strict type comparison in tests.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Unit_test::active"> +<code class="descname">active</code><span class="sig-paren">(</span><span class="optional">[</span><em>$state = TRUE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::active" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$state</strong> (<em>bool</em>) – Whether to enable testing</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Enables/disables unit testing.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Unit_test::result"> +<code class="descname">result</code><span class="sig-paren">(</span><span class="optional">[</span><em>$results = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::result" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$results</strong> (<em>array</em>) – Tests results list</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of raw result data</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>Returns raw tests results data.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Unit_test::set_template"> +<code class="descname">set_template</code><span class="sig-paren">(</span><em>$template</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Unit_test::set_template" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$template</strong> (<em>string</em>) – Test result template</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the template for displaying tests results.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="uri.html" class="btn btn-neutral float-right" title="URI Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="typography.html" class="btn btn-neutral" title="Typography Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html new file mode 100644 index 000000000..5bc677672 --- /dev/null +++ b/user_guide/libraries/uri.html @@ -0,0 +1,890 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>URI Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="User Agent Class" href="user_agent.html"/> + <link rel="prev" title="Unit Testing Class" href="unit_testing.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>URI Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="uri-class"> +<h1>URI Class<a class="headerlink" href="#uri-class" title="Permalink to this headline">¶</a></h1> +<p>The URI Class provides methods that help you retrieve information from +your URI strings. If you use URI routing, you can also retrieve +information about the re-routed segments.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This class is initialized automatically by the system so there +is no need to do it manually.</p> +</div> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#class-reference" id="id1">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id1">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_URI"> +<em class="property">class </em><code class="descname">CI_URI</code><a class="headerlink" href="#CI_URI" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_URI::segment"> +<code class="descname">segment</code><span class="sig-paren">(</span><em>$n</em><span class="optional">[</span>, <em>$no_result = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::segment" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$n</strong> (<em>int</em>) – Segment index number</li> +<li><strong>$no_result</strong> (<em>mixed</em>) – What to return if the searched segment is not found</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Segment value or $no_result value if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to retrieve a specific segment. Where n is the segment +number you wish to retrieve. Segments are numbered from left to right. +For example, if your full URL is this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">news</span><span class="o">/</span><span class="nx">local</span><span class="o">/</span><span class="nx">metro</span><span class="o">/</span><span class="nx">crime_is_up</span> +</pre></div> +</div> +<p>The segment numbers would be this:</p> +<ol class="arabic simple"> +<li>news</li> +<li>local</li> +<li>metro</li> +<li>crime_is_up</li> +</ol> +<p>The optional second parameter defaults to NULL and allows you to set the return value +of this method when the requested URI segment is missing. +For example, this would tell the method to return the number zero in the event of failure:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$product_id</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> +</pre></div> +</div> +<p>It helps avoid having to write code like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">===</span> <span class="k">FALSE</span><span class="p">)</span> +<span class="p">{</span> + <span class="nv">$product_id</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> +<span class="p">}</span> +<span class="k">else</span> +<span class="p">{</span> + <span class="nv">$product_id</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span> +<span class="p">}</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::rsegment"> +<code class="descname">rsegment</code><span class="sig-paren">(</span><em>$n</em><span class="optional">[</span>, <em>$no_result = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::rsegment" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$n</strong> (<em>int</em>) – Segment index number</li> +<li><strong>$no_result</strong> (<em>mixed</em>) – What to return if the searched segment is not found</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Routed segment value or $no_result value if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">segment()</span></code>, except that it lets you retrieve +a specific segment from your re-routed URI in the event you are +using CodeIgniter’s <a class="reference internal" href="../general/routing.html"><span class="doc">URI Routing</span></a> feature.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::slash_segment"> +<code class="descname">slash_segment</code><span class="sig-paren">(</span><em>$n</em><span class="optional">[</span>, <em>$where = 'trailing'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::slash_segment" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$n</strong> (<em>int</em>) – Segment index number</li> +<li><strong>$where</strong> (<em>string</em>) – Where to add the slash (‘trailing’ or ‘leading’)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Segment value, prepended/suffixed with a forward slash, or a slash if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>This method is almost identical to <code class="docutils literal"><span class="pre">segment()</span></code>, except it +adds a trailing and/or leading slash based on the second parameter. +If the parameter is not used, a trailing slash added. Examples:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">slash_segment</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">slash_segment</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'leading'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">slash_segment</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'both'</span><span class="p">);</span> +</pre></div> +</div> +<p>Returns:</p> +<ol class="arabic simple"> +<li>segment/</li> +<li>/segment</li> +<li>/segment/</li> +</ol> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::slash_rsegment"> +<code class="descname">slash_rsegment</code><span class="sig-paren">(</span><em>$n</em><span class="optional">[</span>, <em>$where = 'trailing'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::slash_rsegment" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$n</strong> (<em>int</em>) – Segment index number</li> +<li><strong>$where</strong> (<em>string</em>) – Where to add the slash (‘trailing’ or ‘leading’)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Routed segment value, prepended/suffixed with a forward slash, or a slash if not found</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">slash_segment()</span></code>, except that it lets you +add slashes a specific segment from your re-routed URI in the event you +are using CodeIgniter’s <a class="reference internal" href="../general/routing.html"><span class="doc">URI Routing</span></a> +feature.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::uri_to_assoc"> +<code class="descname">uri_to_assoc</code><span class="sig-paren">(</span><span class="optional">[</span><em>$n = 3</em><span class="optional">[</span>, <em>$default = array()</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::uri_to_assoc" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$n</strong> (<em>int</em>) – Segment index number</li> +<li><strong>$default</strong> (<em>array</em>) – Default values</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Associative URI segments array</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>This method lets you turn URI segments into an associative array of +key/value pairs. Consider this URI:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">user</span><span class="o">/</span><span class="nx">search</span><span class="o">/</span><span class="nx">name</span><span class="o">/</span><span class="nx">joe</span><span class="o">/</span><span class="nx">location</span><span class="o">/</span><span class="nx">UK</span><span class="o">/</span><span class="nx">gender</span><span class="o">/</span><span class="nx">male</span> +</pre></div> +</div> +<p>Using this method you can turn the URI into an associative array with +this prototype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="p">[</span><span class="k">array</span><span class="p">]</span> +<span class="p">(</span> + <span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'joe'</span> + <span class="s1">'location'</span> <span class="o">=></span> <span class="s1">'UK'</span> + <span class="s1">'gender'</span> <span class="o">=></span> <span class="s1">'male'</span> +<span class="p">)</span> +</pre></div> +</div> +<p>The first parameter lets you set an offset, which defaults to 3 since your +URI will normally contain a controller/method pair in the first and second segments. +Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$array</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">uri_to_assoc</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span> +<span class="k">echo</span> <span class="nv">$array</span><span class="p">[</span><span class="s1">'name'</span><span class="p">];</span> +</pre></div> +</div> +<p>The second parameter lets you set default key names, so that the array +returned will always contain expected indexes, even if missing from the URI. +Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$default</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'name'</span><span class="p">,</span> <span class="s1">'gender'</span><span class="p">,</span> <span class="s1">'location'</span><span class="p">,</span> <span class="s1">'type'</span><span class="p">,</span> <span class="s1">'sort'</span><span class="p">);</span> +<span class="nv">$array</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">uri_to_assoc</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="nv">$default</span><span class="p">);</span> +</pre></div> +</div> +<p>If the URI does not contain a value in your default, an array index will +be set to that name, with a value of NULL.</p> +<p>Lastly, if a corresponding value is not found for a given key (if there +is an odd number of URI segments) the value will be set to NULL.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::ruri_to_assoc"> +<code class="descname">ruri_to_assoc</code><span class="sig-paren">(</span><span class="optional">[</span><em>$n = 3</em><span class="optional">[</span>, <em>$default = array()</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::ruri_to_assoc" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$n</strong> (<em>int</em>) – Segment index number</li> +<li><strong>$default</strong> (<em>array</em>) – Default values</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Associative routed URI segments array</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p> +</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">uri_to_assoc()</span></code>, except that it creates +an associative array using the re-routed URI in the event you are using +CodeIgniter’s <a class="reference internal" href="../general/routing.html"><span class="doc">URI Routing</span></a> feature.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::assoc_to_uri"> +<code class="descname">assoc_to_uri</code><span class="sig-paren">(</span><em>$array</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::assoc_to_uri" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$array</strong> (<em>array</em>) – Input array of key/value pairs</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">URI string</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> +</td> +</tr> +</tbody> +</table> +<p>Takes an associative array as input and generates a URI string from it. +The array keys will be included in the string. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$array</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'product'</span> <span class="o">=></span> <span class="s1">'shoes'</span><span class="p">,</span> <span class="s1">'size'</span> <span class="o">=></span> <span class="s1">'large'</span><span class="p">,</span> <span class="s1">'color'</span> <span class="o">=></span> <span class="s1">'red'</span><span class="p">);</span> +<span class="nv">$str</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">assoc_to_uri</span><span class="p">(</span><span class="nv">$array</span><span class="p">);</span> + +<span class="c1">// Produces: product/shoes/size/large/color/red</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::uri_string"> +<code class="descname">uri_string</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::uri_string" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">URI string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string with the complete URI. For example, if this is your full URL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">http</span><span class="o">://</span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">news</span><span class="o">/</span><span class="nx">local</span><span class="o">/</span><span class="mi">345</span> +</pre></div> +</div> +<p>The method would return this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">news</span><span class="o">/</span><span class="nx">local</span><span class="o">/</span><span class="mi">345</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::ruri_string"> +<code class="descname">ruri_string</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::ruri_string" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Routed URI string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">uri_string()</span></code>, except that it returns +the re-routed URI in the event you are using CodeIgniter’s <a class="reference internal" href="../general/routing.html"><span class="doc">URI +Routing</span></a> feature.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::total_segments"> +<code class="descname">total_segments</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::total_segments" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Count of URI segments</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td> +</tr> +</tbody> +</table> +<p>Returns the total number of segments.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::total_rsegments"> +<code class="descname">total_rsegments</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::total_rsegments" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Count of routed URI segments</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">total_segments()</span></code>, except that it returns +the total number of segments in your re-routed URI in the event you are +using CodeIgniter’s <a class="reference internal" href="../general/routing.html"><span class="doc">URI Routing</span></a> feature.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::segment_array"> +<code class="descname">segment_array</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::segment_array" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">URI segments array</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Returns an array containing the URI segments. For example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$segs</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">uri</span><span class="o">-></span><span class="na">segment_array</span><span class="p">();</span> + +<span class="k">foreach</span> <span class="p">(</span><span class="nv">$segs</span> <span class="k">as</span> <span class="nv">$segment</span><span class="p">)</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$segment</span><span class="p">;</span> + <span class="k">echo</span> <span class="s1">'<br />'</span><span class="p">;</span> +<span class="p">}</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_URI::rsegment_array"> +<code class="descname">rsegment_array</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_URI::rsegment_array" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Routed URI segments array</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>This method is identical to <code class="docutils literal"><span class="pre">segment_array()</span></code>, except that it returns +the array of segments in your re-routed URI in the event you are using +CodeIgniter’s <a class="reference internal" href="../general/routing.html"><span class="doc">URI Routing</span></a> feature.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="user_agent.html" class="btn btn-neutral float-right" title="User Agent Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="unit_testing.html" class="btn btn-neutral" title="Unit Testing Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html new file mode 100644 index 000000000..094fc79fa --- /dev/null +++ b/user_guide/libraries/user_agent.html @@ -0,0 +1,931 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>User Agent Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="XML-RPC and XML-RPC Server Classes" href="xmlrpc.html"/> + <link rel="prev" title="URI Class" href="uri.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>User Agent Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="user-agent-class"> +<h1>User Agent Class<a class="headerlink" href="#user-agent-class" title="Permalink to this headline">¶</a></h1> +<p>The User Agent Class provides functions that help identify information +about the browser, mobile device, or robot visiting your site. In +addition you can get referrer information as well as language and +supported character-set information.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-user-agent-class" id="id1">Using the User Agent Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#user-agent-definitions" id="id3">User Agent Definitions</a></li> +<li><a class="reference internal" href="#example" id="id4">Example</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id5">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-user-agent-class"> +<h2><a class="toc-backref" href="#id1">Using the User Agent Class</a><a class="headerlink" href="#using-the-user-agent-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the User Agent class is +initialized in your controller using the $this->load->library function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'user_agent'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the object will be available using: <code class="docutils literal"><span class="pre">$this->agent</span></code></p> +</div> +<div class="section" id="user-agent-definitions"> +<h3><a class="toc-backref" href="#id3">User Agent Definitions</a><a class="headerlink" href="#user-agent-definitions" title="Permalink to this headline">¶</a></h3> +<p>The user agent name definitions are located in a config file located at: +application/config/user_agents.php. You may add items to the various +user agent arrays if needed.</p> +</div> +<div class="section" id="example"> +<h3><a class="toc-backref" href="#id4">Example</a><a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h3> +<p>When the User Agent class is initialized it will attempt to determine +whether the user agent browsing your site is a web browser, a mobile +device, or a robot. It will also gather the platform information if it +is available.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'user_agent'</span><span class="p">);</span> + +<span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_browser</span><span class="p">())</span> +<span class="p">{</span> + <span class="nv">$agent</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">browser</span><span class="p">()</span><span class="o">.</span><span class="s1">' '</span><span class="o">.</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">version</span><span class="p">();</span> +<span class="p">}</span> +<span class="k">elseif</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_robot</span><span class="p">())</span> +<span class="p">{</span> + <span class="nv">$agent</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">robot</span><span class="p">();</span> +<span class="p">}</span> +<span class="k">elseif</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_mobile</span><span class="p">())</span> +<span class="p">{</span> + <span class="nv">$agent</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">mobile</span><span class="p">();</span> +<span class="p">}</span> +<span class="k">else</span> +<span class="p">{</span> + <span class="nv">$agent</span> <span class="o">=</span> <span class="s1">'Unidentified User Agent'</span><span class="p">;</span> +<span class="p">}</span> + +<span class="k">echo</span> <span class="nv">$agent</span><span class="p">;</span> + +<span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">platform</span><span class="p">();</span> <span class="c1">// Platform info (Windows, Linux, Mac, etc.)</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id5">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_User_agent"> +<em class="property">class </em><code class="descname">CI_User_agent</code><a class="headerlink" href="#CI_User_agent" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_User_agent::is_browser"> +<code class="descname">is_browser</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::is_browser" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Optional browser name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the user agent is a (specified) browser, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Returns TRUE/FALSE (boolean) if the user agent is a known web browser.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_browser</span><span class="p">(</span><span class="s1">'Safari'</span><span class="p">))</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'You are using Safari.'</span><span class="p">;</span> +<span class="p">}</span> +<span class="k">elseif</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_browser</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'You are using a browser.'</span><span class="p">;</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The string “Safari” in this example is an array key in the list of browser definitions. +You can find this list in <strong>application/config/user_agents.php</strong> if you want to add new +browsers or change the stings.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::is_mobile"> +<code class="descname">is_mobile</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::is_mobile" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Optional mobile device name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the user agent is a (specified) mobile device, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_mobile</span><span class="p">(</span><span class="s1">'iphone'</span><span class="p">))</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'iphone/home'</span><span class="p">);</span> +<span class="p">}</span> +<span class="k">elseif</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_mobile</span><span class="p">())</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'mobile/home'</span><span class="p">);</span> +<span class="p">}</span> +<span class="k">else</span> +<span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">view</span><span class="p">(</span><span class="s1">'web/home'</span><span class="p">);</span> +<span class="p">}</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::is_robot"> +<code class="descname">is_robot</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::is_robot" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$key</strong> (<em>string</em>) – Optional robot name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the user agent is a (specified) robot, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Returns TRUE/FALSE (boolean) if the user agent is a known robot.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">The user agent library only contains the most common robot definitions. It is not a complete list of bots. +There are hundreds of them so searching for each one would not be very efficient. If you find that some bots +that commonly visit your site are missing from the list you can add them to your +<strong>application/config/user_agents.php</strong> file.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::is_referral"> +<code class="descname">is_referral</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::is_referral" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE if the user agent is a referral, FALSE if not</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>Returns TRUE/FALSE (boolean) if the user agent was referred from another site.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::browser"> +<code class="descname">browser</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::browser" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Detected browser or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the name of the web browser viewing your site.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::version"> +<code class="descname">version</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::version" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Detected browser version or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the version number of the web browser viewing your site.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::mobile"> +<code class="descname">mobile</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::mobile" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Detected mobile device brand or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the name of the mobile device viewing your site.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::robot"> +<code class="descname">robot</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::robot" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Detected robot name or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the name of the robot viewing your site.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::platform"> +<code class="descname">platform</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::platform" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Detected operating system or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the platform viewing your site (Linux, Windows, OS X, etc.).</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::referrer"> +<code class="descname">referrer</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::referrer" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Detected referrer or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>The referrer, if the user agent was referred from another site. Typically you’ll test for this as follows:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">is_referral</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">referrer</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::agent_string"> +<code class="descname">agent_string</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::agent_string" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Full user agent string or an empty string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns a string containing the full user agent string. Typically it will be something like this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">Mozilla</span><span class="o">/</span><span class="mf">5.0</span> <span class="p">(</span><span class="nx">Macintosh</span><span class="p">;</span> <span class="nx">U</span><span class="p">;</span> <span class="nx">Intel</span> <span class="nx">Mac</span> <span class="nx">OS</span> <span class="nx">X</span><span class="p">;</span> <span class="nx">en</span><span class="o">-</span><span class="nx">US</span><span class="p">;</span> <span class="nx">rv</span><span class="o">:</span><span class="mf">1.8</span><span class="o">.</span><span class="mf">0.4</span><span class="p">)</span> <span class="nx">Gecko</span><span class="o">/</span><span class="mi">20060613</span> <span class="nx">Camino</span><span class="o">/</span><span class="mf">1.0</span><span class="o">.</span><span class="mi">2</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::accept_lang"> +<code class="descname">accept_lang</code><span class="sig-paren">(</span><span class="optional">[</span><em>$lang = 'en'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::accept_lang" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$lang</strong> (<em>string</em>) – Language key</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if provided language is accepted, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you determine if the user agent accepts a particular language. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">accept_lang</span><span class="p">(</span><span class="s1">'en'</span><span class="p">))</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'You accept English!'</span><span class="p">;</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is not typically very reliable since some browsers do not provide language info, +and even among those that do, it is not always accurate.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::languages"> +<code class="descname">languages</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::languages" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array list of accepted languages</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Returns an array of languages supported by the user agent.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::accept_charset"> +<code class="descname">accept_charset</code><span class="sig-paren">(</span><span class="optional">[</span><em>$charset = 'utf-8'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::accept_charset" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$charset</strong> (<em>string</em>) – Character set</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the character set is accepted, FALSE if not</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Lets you determine if the user agent accepts a particular character set. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">agent</span><span class="o">-></span><span class="na">accept_charset</span><span class="p">(</span><span class="s1">'utf-8'</span><span class="p">))</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="s1">'You browser supports UTF-8!'</span><span class="p">;</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is not typically very reliable since some browsers do not provide character-set info, +and even among those that do, it is not always accurate.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::charsets"> +<code class="descname">charsets</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::charsets" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array list of accepted character sets</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> +</tr> +</tbody> +</table> +<p>Returns an array of character sets accepted by the user agent.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_User_agent::parse"> +<code class="descname">parse</code><span class="sig-paren">(</span><em>$string</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_User_agent::parse" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$string</strong> (<em>string</em>) – A custom user-agent string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Parses a custom user-agent string, different from the one reported by the current visitor.</p> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="xmlrpc.html" class="btn btn-neutral float-right" title="XML-RPC and XML-RPC Server Classes">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="uri.html" class="btn btn-neutral" title="URI Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/xmlrpc.html b/user_guide/libraries/xmlrpc.html new file mode 100644 index 000000000..48a476a6f --- /dev/null +++ b/user_guide/libraries/xmlrpc.html @@ -0,0 +1,1151 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>XML-RPC and XML-RPC Server Classes — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Zip Encoding Class" href="zip.html"/> + <link rel="prev" title="User Agent Class" href="user_agent.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>XML-RPC and XML-RPC Server Classes</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="xml-rpc-and-xml-rpc-server-classes"> +<h1>XML-RPC and XML-RPC Server Classes<a class="headerlink" href="#xml-rpc-and-xml-rpc-server-classes" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s XML-RPC classes permit you to send requests to another +server, or set up your own XML-RPC server to receive requests.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#what-is-xml-rpc" id="id3">What is XML-RPC?</a></li> +<li><a class="reference internal" href="#using-the-xml-rpc-class" id="id4">Using the XML-RPC Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id5">Initializing the Class</a></li> +<li><a class="reference internal" href="#sending-xml-rpc-requests" id="id6">Sending XML-RPC Requests</a><ul> +<li><a class="reference internal" href="#explanation" id="id7">Explanation</a></li> +</ul> +</li> +<li><a class="reference internal" href="#anatomy-of-a-request" id="id8">Anatomy of a Request</a></li> +<li><a class="reference internal" href="#creating-an-xml-rpc-server" id="id9">Creating an XML-RPC Server</a></li> +<li><a class="reference internal" href="#processing-server-requests" id="id10">Processing Server Requests</a><ul> +<li><a class="reference internal" href="#notes" id="id11">Notes:</a></li> +</ul> +</li> +<li><a class="reference internal" href="#formatting-a-response" id="id12">Formatting a Response</a></li> +<li><a class="reference internal" href="#sending-an-error-response" id="id13">Sending an Error Response</a></li> +<li><a class="reference internal" href="#creating-your-own-client-and-server" id="id14">Creating Your Own Client and Server</a><ul> +<li><a class="reference internal" href="#the-client" id="id15">The Client</a></li> +<li><a class="reference internal" href="#the-server" id="id16">The Server</a></li> +<li><a class="reference internal" href="#try-it" id="id17">Try it!</a></li> +</ul> +</li> +<li><a class="reference internal" href="#using-associative-arrays-in-a-request-parameter" id="id18">Using Associative Arrays In a Request Parameter</a></li> +<li><a class="reference internal" href="#id2" id="id19">Data Types</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id20">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="what-is-xml-rpc"> +<h2><a class="toc-backref" href="#id3">What is XML-RPC?</a><a class="headerlink" href="#what-is-xml-rpc" title="Permalink to this headline">¶</a></h2> +<p>Quite simply it is a way for two computers to communicate over the +internet using XML. One computer, which we will call the client, sends +an XML-RPC <strong>request</strong> to another computer, which we will call the +server. Once the server receives and processes the request it will send +back a <strong>response</strong> to the client.</p> +<p>For example, using the MetaWeblog API, an XML-RPC Client (usually a +desktop publishing tool) will send a request to an XML-RPC Server +running on your site. This request might be a new weblog entry being +sent for publication, or it could be a request for an existing entry for +editing. When the XML-RPC Server receives this request it will examine +it to determine which class/method should be called to process the +request. Once processed, the server will then send back a response +message.</p> +<p>For detailed specifications, you can visit the <a class="reference external" href="http://www.xmlrpc.com/">XML-RPC</a> site.</p> +</div> +<div class="section" id="using-the-xml-rpc-class"> +<h2><a class="toc-backref" href="#id4">Using the XML-RPC Class</a><a class="headerlink" href="#using-the-xml-rpc-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id5">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the XML-RPC and XML-RPCS classes +are initialized in your controller using the $this->load->library +function:</p> +<p>To load the XML-RPC class you will use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the xml-rpc library object will be available using: +$this->xmlrpc</p> +<p>To load the XML-RPC Server class you will use:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpcs'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the xml-rpcs library object will be available using: +$this->xmlrpcs</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">When using the XML-RPC Server class you must load BOTH the +XML-RPC class and the XML-RPC Server class.</p> +</div> +</div> +<div class="section" id="sending-xml-rpc-requests"> +<h3><a class="toc-backref" href="#id6">Sending XML-RPC Requests</a><a class="headerlink" href="#sending-xml-rpc-requests" title="Permalink to this headline">¶</a></h3> +<p>To send a request to an XML-RPC server you must specify the following +information:</p> +<ul class="simple"> +<li>The URL of the server</li> +<li>The method on the server you wish to call</li> +<li>The <em>request</em> data (explained below).</li> +</ul> +<p>Here is a basic example that sends a simple Weblogs.com ping to the +<a class="reference external" href="http://pingomatic.com/">Ping-o-Matic</a></p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">server</span><span class="p">(</span><span class="s1">'http://rpc.pingomatic.com/'</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">method</span><span class="p">(</span><span class="s1">'weblogUpdates.ping'</span><span class="p">);</span> + +<span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'My Photoblog'</span><span class="p">,</span> <span class="s1">'http://www.my-site.com/photoblog/'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span> + +<span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_request</span><span class="p">())</span> +<span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">display_error</span><span class="p">();</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="section" id="explanation"> +<h4><a class="toc-backref" href="#id7">Explanation</a><a class="headerlink" href="#explanation" title="Permalink to this headline">¶</a></h4> +<p>The above code initializes the XML-RPC class, sets the server URL and +method to be called (weblogUpdates.ping). The request (in this case, the +title and URL of your site) is placed into an array for transportation, +and compiled using the request() function. Lastly, the full request is +sent. If the send_request() method returns false we will display the +error message sent back from the XML-RPC Server.</p> +</div> +</div> +<div class="section" id="anatomy-of-a-request"> +<h3><a class="toc-backref" href="#id8">Anatomy of a Request</a><a class="headerlink" href="#anatomy-of-a-request" title="Permalink to this headline">¶</a></h3> +<p>An XML-RPC request is simply the data you are sending to the XML-RPC +server. Each piece of data in a request is referred to as a request +parameter. The above example has two parameters: The URL and title of +your site. When the XML-RPC server receives your request, it will look +for parameters it requires.</p> +<p>Request parameters must be placed into an array for transportation, and +each parameter can be one of seven data types (strings, numbers, dates, +etc.). If your parameters are something other than strings you will have +to include the data type in the request array.</p> +<p>Here is an example of a simple array with three parameters:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'Doe'</span><span class="p">,</span> <span class="s1">'www.some-site.com'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span> +</pre></div> +</div> +<p>If you use data types other than strings, or if you have several +different data types, you will place each parameter into its own array, +with the data type in the second position:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'Doe'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="k">FALSE</span><span class="p">,</span> <span class="s1">'boolean'</span><span class="p">),</span> + <span class="k">array</span><span class="p">(</span><span class="mi">12345</span><span class="p">,</span> <span class="s1">'int'</span><span class="p">)</span> +<span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span> +</pre></div> +</div> +<p>The <a class="reference external" href="#datatypes">Data Types</a> section below has a full list of data +types.</p> +</div> +<div class="section" id="creating-an-xml-rpc-server"> +<h3><a class="toc-backref" href="#id9">Creating an XML-RPC Server</a><a class="headerlink" href="#creating-an-xml-rpc-server" title="Permalink to this headline">¶</a></h3> +<p>An XML-RPC Server acts as a traffic cop of sorts, waiting for incoming +requests and redirecting them to the appropriate functions for +processing.</p> +<p>To create your own XML-RPC server involves initializing the XML-RPC +Server class in your controller where you expect the incoming request to +appear, then setting up an array with mapping instructions so that +incoming requests can be sent to the appropriate class and method for +processing.</p> +<p>Here is an example to illustrate:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpcs'</span><span class="p">);</span> + +<span class="nv">$config</span><span class="p">[</span><span class="s1">'functions'</span><span class="p">][</span><span class="s1">'new_post'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'function'</span> <span class="o">=></span> <span class="s1">'My_blog.new_entry'</span><span class="p">);</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'functions'</span><span class="p">][</span><span class="s1">'update_post'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'function'</span> <span class="o">=></span> <span class="s1">'My_blog.update_entry'</span><span class="p">);</span> +<span class="nv">$config</span><span class="p">[</span><span class="s1">'object'</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpcs</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpcs</span><span class="o">-></span><span class="na">serve</span><span class="p">();</span> +</pre></div> +</div> +<p>The above example contains an array specifying two method requests that +the Server allows. The allowed methods are on the left side of the +array. When either of those are received, they will be mapped to the +class and method on the right.</p> +<p>The ‘object’ key is a special key that you pass an instantiated class +object with, which is necessary when the method you are mapping to is +not part of the CodeIgniter super object.</p> +<p>In other words, if an XML-RPC Client sends a request for the new_post +method, your server will load the My_blog class and call the new_entry +function. If the request is for the update_post method, your server +will load the My_blog class and call the <code class="docutils literal"><span class="pre">update_entry()</span></code> method.</p> +<p>The function names in the above example are arbitrary. You’ll decide +what they should be called on your server, or if you are using +standardized APIs, like the Blogger or MetaWeblog API, you’ll use their +function names.</p> +<p>There are two additional configuration keys you may make use of when +initializing the server class: debug can be set to TRUE in order to +enable debugging, and xss_clean may be set to FALSE to prevent sending +data through the Security library’s <code class="docutils literal"><span class="pre">xss_clean()</span></code> method.</p> +</div> +<div class="section" id="processing-server-requests"> +<h3><a class="toc-backref" href="#id10">Processing Server Requests</a><a class="headerlink" href="#processing-server-requests" title="Permalink to this headline">¶</a></h3> +<p>When the XML-RPC Server receives a request and loads the class/method +for processing, it will pass an object to that method containing the +data sent by the client.</p> +<p>Using the above example, if the new_post method is requested, the +server will expect a class to exist with this prototype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">My_blog</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">new_post</span><span class="p">(</span><span class="nv">$request</span><span class="p">)</span> + <span class="p">{</span> + + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +<p>The $request variable is an object compiled by the Server, which +contains the data sent by the XML-RPC Client. Using this object you will +have access to the <em>request parameters</em> enabling you to process the +request. When you are done you will send a Response back to the Client.</p> +<p>Below is a real-world example, using the Blogger API. One of the methods +in the Blogger API is <code class="docutils literal"><span class="pre">getUserInfo()</span></code>. Using this method, an XML-RPC +Client can send the Server a username and password, in return the Server +sends back information about that particular user (nickname, user ID, +email address, etc.). Here is how the processing function might look:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">My_blog</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">getUserInfo</span><span class="p">(</span><span class="nv">$request</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$username</span> <span class="o">=</span> <span class="s1">'smitty'</span><span class="p">;</span> + <span class="nv">$password</span> <span class="o">=</span> <span class="s1">'secretsmittypass'</span><span class="p">;</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> + + <span class="nv">$parameters</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-></span><span class="na">output_parameters</span><span class="p">();</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="nv">$username</span> <span class="o">&&</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">!=</span> <span class="nv">$password</span><span class="p">)</span> + <span class="p">{</span> + <span class="k">return</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_error_message</span><span class="p">(</span><span class="s1">'100'</span><span class="p">,</span> <span class="s1">'Invalid Access'</span><span class="p">);</span> + <span class="p">}</span> + + <span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'nickname'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'Smitty'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'userid'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'99'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'url'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'http://yoursite.com'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'email'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'jsmith@yoursite.com'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'lastname'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'Smith'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'firstname'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">)</span> + <span class="p">),</span> + <span class="s1">'struct'</span> + <span class="p">);</span> + + <span class="k">return</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_response</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +<div class="section" id="notes"> +<h4><a class="toc-backref" href="#id11">Notes:</a><a class="headerlink" href="#notes" title="Permalink to this headline">¶</a></h4> +<p>The <code class="docutils literal"><span class="pre">output_parameters()</span></code> method retrieves an indexed array +corresponding to the request parameters sent by the client. In the above +example, the output parameters will be the username and password.</p> +<p>If the username and password sent by the client were not valid, and +error message is returned using <code class="docutils literal"><span class="pre">send_error_message()</span></code>.</p> +<p>If the operation was successful, the client will be sent back a response +array containing the user’s info.</p> +</div> +</div> +<div class="section" id="formatting-a-response"> +<h3><a class="toc-backref" href="#id12">Formatting a Response</a><a class="headerlink" href="#formatting-a-response" title="Permalink to this headline">¶</a></h3> +<p>Similar to <em>Requests</em>, <em>Responses</em> must be formatted as an array. +However, unlike requests, a response is an array <strong>that contains a +single item</strong>. This item can be an array with several additional arrays, +but there can be only one primary array index. In other words, the basic +prototype is this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'Response data'</span><span class="p">,</span> <span class="s1">'array'</span><span class="p">);</span> +</pre></div> +</div> +<p>Responses, however, usually contain multiple pieces of information. In +order to accomplish this we must put the response into its own array so +that the primary array continues to contain a single piece of data. +Here’s an example showing how this might be accomplished:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'first_name'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'John'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'last_name'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'Doe'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> + <span class="s1">'member_id'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="mi">123435</span><span class="p">,</span> <span class="s1">'int'</span><span class="p">),</span> + <span class="s1">'todo_list'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'clean house'</span><span class="p">,</span> <span class="s1">'call mom'</span><span class="p">,</span> <span class="s1">'water plants'</span><span class="p">),</span> <span class="s1">'array'</span><span class="p">),</span> + <span class="p">),</span> + <span class="s1">'struct'</span> +<span class="p">);</span> +</pre></div> +</div> +<p>Notice that the above array is formatted as a struct. This is the most +common data type for responses.</p> +<p>As with Requests, a response can be one of the seven data types listed +in the <a class="reference external" href="#datatypes">Data Types</a> section.</p> +</div> +<div class="section" id="sending-an-error-response"> +<h3><a class="toc-backref" href="#id13">Sending an Error Response</a><a class="headerlink" href="#sending-an-error-response" title="Permalink to this headline">¶</a></h3> +<p>If you need to send the client an error response you will use the +following:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">return</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_error_message</span><span class="p">(</span><span class="s1">'123'</span><span class="p">,</span> <span class="s1">'Requested data not available'</span><span class="p">);</span> +</pre></div> +</div> +<p>The first parameter is the error number while the second parameter is +the error message.</p> +</div> +<div class="section" id="creating-your-own-client-and-server"> +<h3><a class="toc-backref" href="#id14">Creating Your Own Client and Server</a><a class="headerlink" href="#creating-your-own-client-and-server" title="Permalink to this headline">¶</a></h3> +<p>To help you understand everything we’ve covered thus far, let’s create a +couple controllers that act as XML-RPC Client and Server. You’ll use the +Client to send a request to the Server and receive a response.</p> +<div class="section" id="the-client"> +<h4><a class="toc-backref" href="#id15">The Client</a><a class="headerlink" href="#the-client" title="Permalink to this headline">¶</a></h4> +<p>Using a text editor, create a controller called Xmlrpc_client.php. In +it, place this code and save it to your application/controllers/ +folder:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Xmlrpc_client</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">helper</span><span class="p">(</span><span class="s1">'url'</span><span class="p">);</span> + <span class="nv">$server_url</span> <span class="o">=</span> <span class="nx">site_url</span><span class="p">(</span><span class="s1">'xmlrpc_server'</span><span class="p">);</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">server</span><span class="p">(</span><span class="nv">$server_url</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">method</span><span class="p">(</span><span class="s1">'Greetings'</span><span class="p">);</span> + + <span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'How is it going?'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_request</span><span class="p">())</span> + <span class="p">{</span> + <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">display_error</span><span class="p">();</span> + <span class="p">}</span> + <span class="k">else</span> + <span class="p">{</span> + <span class="k">echo</span> <span class="s1">'<pre>'</span><span class="p">;</span> + <span class="nb">print_r</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">display_response</span><span class="p">());</span> + <span class="k">echo</span> <span class="s1">'</pre>'</span><span class="p">;</span> + <span class="p">}</span> + <span class="p">}</span> +<span class="p">}</span> +<span class="cp">?></span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">In the above code we are using a “url helper”. You can find more +information in the <a class="reference internal" href="../general/helpers.html"><span class="doc">Helpers Functions</span></a> page.</p> +</div> +</div> +<div class="section" id="the-server"> +<h4><a class="toc-backref" href="#id16">The Server</a><a class="headerlink" href="#the-server" title="Permalink to this headline">¶</a></h4> +<p>Using a text editor, create a controller called Xmlrpc_server.php. In +it, place this code and save it to your application/controllers/ +folder:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> + +<span class="k">class</span> <span class="nc">Xmlrpc_server</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> + <span class="p">{</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpc'</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'xmlrpcs'</span><span class="p">);</span> + + <span class="nv">$config</span><span class="p">[</span><span class="s1">'functions'</span><span class="p">][</span><span class="s1">'Greetings'</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'function'</span> <span class="o">=></span> <span class="s1">'Xmlrpc_server.process'</span><span class="p">);</span> + + <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpcs</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> + <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpcs</span><span class="o">-></span><span class="na">serve</span><span class="p">();</span> + <span class="p">}</span> + + + <span class="k">public</span> <span class="k">function</span> <span class="nf">process</span><span class="p">(</span><span class="nv">$request</span><span class="p">)</span> + <span class="p">{</span> + <span class="nv">$parameters</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-></span><span class="na">output_parameters</span><span class="p">();</span> + + <span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'you_said'</span> <span class="o">=></span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> + <span class="s1">'i_respond'</span> <span class="o">=></span> <span class="s1">'Not bad at all.'</span> + <span class="p">),</span> + <span class="s1">'struct'</span> + <span class="p">);</span> + + <span class="k">return</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_response</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span> + <span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> +</div> +<div class="section" id="try-it"> +<h4><a class="toc-backref" href="#id17">Try it!</a><a class="headerlink" href="#try-it" title="Permalink to this headline">¶</a></h4> +<p>Now visit the your site using a URL similar to this:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">xmlrpc_client</span><span class="o">/</span> +</pre></div> +</div> +<p>You should now see the message you sent to the server, and its response +back to you.</p> +<p>The client you created sends a message (“How’s is going?”) to the +server, along with a request for the “Greetings” method. The Server +receives the request and maps it to the <code class="docutils literal"><span class="pre">process()</span></code> method, where a +response is sent back.</p> +</div> +</div> +<div class="section" id="using-associative-arrays-in-a-request-parameter"> +<h3><a class="toc-backref" href="#id18">Using Associative Arrays In a Request Parameter</a><a class="headerlink" href="#using-associative-arrays-in-a-request-parameter" title="Permalink to this headline">¶</a></h3> +<p>If you wish to use an associative array in your method parameters you +will need to use a struct datatype:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="k">array</span><span class="p">(</span> + <span class="c1">// Param 0</span> + <span class="k">array</span><span class="p">(</span><span class="s1">'name'</span> <span class="o">=></span> <span class="s1">'John'</span><span class="p">),</span> + <span class="s1">'struct'</span> + <span class="p">),</span> + <span class="k">array</span><span class="p">(</span> + <span class="c1">// Param 1</span> + <span class="k">array</span><span class="p">(</span> + <span class="s1">'size'</span> <span class="o">=></span> <span class="s1">'large'</span><span class="p">,</span> + <span class="s1">'shape'</span><span class="o">=></span><span class="s1">'round'</span> + <span class="p">),</span> + <span class="s1">'struct'</span> + <span class="p">)</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span> +</pre></div> +</div> +<p>You can retrieve the associative array when processing the request in +the Server.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$parameters</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-></span><span class="na">output_parameters</span><span class="p">();</span> +<span class="nv">$name</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">'name'</span><span class="p">];</span> +<span class="nv">$size</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s1">'size'</span><span class="p">];</span> +<span class="nv">$shape</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s1">'shape'</span><span class="p">];</span> +</pre></div> +</div> +</div> +<div class="section" id="id2"> +<h3><a class="toc-backref" href="#id19">Data Types</a><a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3> +<p>According to the <a class="reference external" href="http://www.xmlrpc.com/spec">XML-RPC spec</a> there are +seven types of values that you can send via XML-RPC:</p> +<ul class="simple"> +<li><em>int</em> or <em>i4</em></li> +<li><em>boolean</em></li> +<li><em>string</em></li> +<li><em>double</em></li> +<li><em>dateTime.iso8601</em></li> +<li><em>base64</em></li> +<li><em>struct</em> (contains array of values)</li> +<li><em>array</em> (contains array of values)</li> +</ul> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id20">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Xmlrpc"> +<em class="property">class </em><code class="descname">CI_Xmlrpc</code><a class="headerlink" href="#CI_Xmlrpc" title="Permalink to this definition">¶</a></dt> +<dd><dl class="method"> +<dt id="CI_Xmlrpc::initialize"> +<code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>$config = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::initialize" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$config</strong> (<em>array</em>) – Configuration data</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Initializes the XML-RPC library. Accepts an associative array containing your settings.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::server"> +<code class="descname">server</code><span class="sig-paren">(</span><em>$url</em><span class="optional">[</span>, <em>$port = 80</em><span class="optional">[</span>, <em>$proxy = FALSE</em><span class="optional">[</span>, <em>$proxy_port = 8080</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::server" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$url</strong> (<em>string</em>) – XML-RPC server URL</li> +<li><strong>$port</strong> (<em>int</em>) – Server port</li> +<li><strong>$proxy</strong> (<em>string</em>) – Optional proxy</li> +<li><strong>$proxy_port</strong> (<em>int</em>) – Proxy listening port</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the URL and port number of the server to which a request is to be sent:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">server</span><span class="p">(</span><span class="s1">'http://www.sometimes.com/pings.php'</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span> +</pre></div> +</div> +<p>Basic HTTP authentication is also supported, simply add it to the server URL:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">server</span><span class="p">(</span><span class="s1">'http://user:pass@localhost/'</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::timeout"> +<code class="descname">timeout</code><span class="sig-paren">(</span><em>$seconds = 5</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::timeout" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$seconds</strong> (<em>int</em>) – Timeout in seconds</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Set a time out period (in seconds) after which the request will be canceled:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">timeout</span><span class="p">(</span><span class="mi">6</span><span class="p">);</span> +</pre></div> +</div> +<p>This timeout period will be used both for an initial connection to +the remote server, as well as for getting a response from it. +Make sure you set the timeout before calling <code class="docutils literal"><span class="pre">send_request()</span></code>.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::method"> +<code class="descname">method</code><span class="sig-paren">(</span><em>$function</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::method" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$function</strong> (<em>string</em>) – Method name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Sets the method that will be requested from the XML-RPC server:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">method</span><span class="p">(</span><span class="s1">'method'</span><span class="p">);</span> +</pre></div> +</div> +<p>Where method is the name of the method.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::request"> +<code class="descname">request</code><span class="sig-paren">(</span><em>$incoming</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::request" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$incoming</strong> (<em>array</em>) – Request data</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Takes an array of data and builds request to be sent to XML-RPC server:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'My Photoblog'</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">),</span> <span class="s1">'http://www.yoursite.com/photoblog/'</span><span class="p">);</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::send_request"> +<code class="descname">send_request</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::send_request" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +<p>The request sending method. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::display_error"> +<code class="descname">display_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::display_error" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Error message string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns an error message as a string if your request failed for some reason.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">display_error</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::display_response"> +<code class="descname">display_response</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::display_response" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Response</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td> +</tr> +</tbody> +</table> +<p>Returns the response from the remote server once request is received. The response will typically be an associative array.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">display_response</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Xmlrpc::send_error_message"> +<code class="descname">send_error_message</code><span class="sig-paren">(</span><em>$number</em>, <em>$message</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::send_error_message" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$number</strong> (<em>int</em>) – Error number</li> +<li><strong>$message</strong> (<em>string</em>) – Error message</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">XML_RPC_Response instance</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">XML_RPC_Response</p> +</td> +</tr> +</tbody> +</table> +<p>This method lets you send an error message from your server to the client. +First parameter is the error number while the second parameter is the error message.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">return</span> <span class="nv">$this</span><span class="o">-></span><span class="na">xmlrpc</span><span class="o">-></span><span class="na">send_error_message</span><span class="p">(</span><span class="mi">123</span><span class="p">,</span> <span class="s1">'Requested data not available'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="zip.html" class="btn btn-neutral float-right" title="Zip Encoding Class">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="user_agent.html" class="btn btn-neutral" title="User Agent Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html new file mode 100644 index 000000000..65d79df39 --- /dev/null +++ b/user_guide/libraries/zip.html @@ -0,0 +1,846 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Zip Encoding Class — CodeIgniter 3.1.11 documentation</title> + + + + + <link rel="shortcut icon" href="../_static/ci-icon.ico"/> + + + + <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'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../genindex.html"/> + <link rel="search" title="Search" href="../search.html"/> + <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/> + <link rel="up" title="Libraries" href="index.html"/> + <link rel="next" title="Database Reference" href="../database/index.html"/> + <link rel="prev" title="XML-RPC and XML-RPC Server Classes" href="xmlrpc.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div id="nav"> + <div id="nav_inner"> + + + + <div id="pulldown-menu" class="ciNav"> + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + </div> + + + </div> +</div> +<div id="nav2"> + <a href="#" id="openToc"> + <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" /> + </a> +</div> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + + <a href="../index.html" class="fa fa-home"> CodeIgniter</a> + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> +<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> +<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> +<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> +</ul> +</li> +</ul> +<ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> +<li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> +<li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Zip Encoding Class</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> +<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> +</ul> +</li> +</ul> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> +<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> +</ul> +</li> +</ul> + + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">CodeIgniter</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html">Docs</a> »</li> + + <li><a href="index.html">Libraries</a> »</li> + + <li>Zip Encoding Class</li> + <li class="wy-breadcrumbs-aside"> + + </li> + <div style="float:right;margin-left:5px;" id="closeMe"> + <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> + </div> + </ul> + <hr/> +</div> + <div role="main" class="document"> + + <div class="section" id="zip-encoding-class"> +<h1>Zip Encoding Class<a class="headerlink" href="#zip-encoding-class" title="Permalink to this headline">¶</a></h1> +<p>CodeIgniter’s Zip Encoding Class permits you to create Zip archives. +Archives can be downloaded to your desktop or saved to a directory.</p> +<div class="contents local topic" id="contents"> +<ul class="simple"> +<li><a class="reference internal" href="#using-the-zip-encoding-class" id="id1">Using the Zip Encoding Class</a><ul> +<li><a class="reference internal" href="#initializing-the-class" id="id2">Initializing the Class</a></li> +<li><a class="reference internal" href="#usage-example" id="id3">Usage Example</a></li> +</ul> +</li> +<li><a class="reference internal" href="#class-reference" id="id4">Class Reference</a></li> +</ul> +</div> +<div class="custom-index container"></div><div class="section" id="using-the-zip-encoding-class"> +<h2><a class="toc-backref" href="#id1">Using the Zip Encoding Class</a><a class="headerlink" href="#using-the-zip-encoding-class" title="Permalink to this headline">¶</a></h2> +<div class="section" id="initializing-the-class"> +<h3><a class="toc-backref" href="#id2">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3> +<p>Like most other classes in CodeIgniter, the Zip class is initialized in +your controller using the $this->load->library function:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'zip'</span><span class="p">);</span> +</pre></div> +</div> +<p>Once loaded, the Zip library object will be available using:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">zip</span> +</pre></div> +</div> +</div> +<div class="section" id="usage-example"> +<h3><a class="toc-backref" href="#id3">Usage Example</a><a class="headerlink" href="#usage-example" title="Permalink to this headline">¶</a></h3> +<p>This example demonstrates how to compress a file, save it to a folder on +your server, and download it to your desktop.</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="s1">'mydata1.txt'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="s1">'A Data String!'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="c1">// Write the zip file to a folder on your server. Name it "my_backup.zip"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">archive</span><span class="p">(</span><span class="s1">'/path/to/directory/my_backup.zip'</span><span class="p">);</span> + +<span class="c1">// Download the file to your desktop. Name it "my_backup.zip"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'my_backup.zip'</span><span class="p">);</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="class-reference"> +<h2><a class="toc-backref" href="#id4">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> +<dl class="class"> +<dt id="CI_Zip"> +<em class="property">class </em><code class="descname">CI_Zip</code><a class="headerlink" href="#CI_Zip" title="Permalink to this definition">¶</a></dt> +<dd><dl class="attribute"> +<dt> +<code class="descname">$compression_level = 2</code></dt> +<dd><p>The compression level to use.</p> +<p>It can range from 0 to 9, with 9 being the highest and 0 effectively disabling compression:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">compression_level</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::add_data"> +<code class="descname">add_data</code><span class="sig-paren">(</span><em>$filepath</em><span class="optional">[</span>, <em>$data = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::add_data" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filepath</strong> (<em>mixed</em>) – A single file path or an array of file => data pairs</li> +<li><strong>$data</strong> (<em>array</em>) – File contents (ignored if $filepath is an array)</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Adds data to the Zip archive. Can work both in single and multiple files mode.</p> +<p>When adding a single file, the first parameter must contain the name you would +like given to the file and the second must contain the file contents:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="s1">'mydata1.txt'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="s1">'A Data String!'</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="nv">$name</span> <span class="o">=</span> <span class="s1">'mydata2.txt'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="s1">'Another Data String!'</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>When adding multiple files, the first parameter must contain <em>file => contents</em> pairs +and the second parameter is ignored:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> + <span class="s1">'mydata1.txt'</span> <span class="o">=></span> <span class="s1">'A Data String!'</span><span class="p">,</span> + <span class="s1">'mydata2.txt'</span> <span class="o">=></span> <span class="s1">'Another Data String!'</span> +<span class="p">);</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>If you would like your compressed data organized into sub-directories, simply include +the path as part of the filename(s):</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="s1">'personal/my_bio.txt'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="s1">'I was born in an elevator...'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +</pre></div> +</div> +<p>The above example will place my_bio.txt inside a folder called personal.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::add_dir"> +<code class="descname">add_dir</code><span class="sig-paren">(</span><em>$directory</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::add_dir" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$directory</strong> (<em>mixed</em>) – Directory name string or an array of multiple directories</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to add a directory. Usually this method is unnecessary since you can place +your data into directories when using <code class="docutils literal"><span class="pre">$this->zip->add_data()</span></code>, but if you would like +to create an empty directory you can do so:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_dir</span><span class="p">(</span><span class="s1">'myfolder'</span><span class="p">);</span> <span class="c1">// Creates a directory called "myfolder"</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::read_file"> +<code class="descname">read_file</code><span class="sig-paren">(</span><em>$path</em><span class="optional">[</span>, <em>$archive_filepath = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::read_file" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Path to file</li> +<li><strong>$archive_filepath</strong> (<em>mixed</em>) – New file name/path (string) or (boolean) whether to maintain the original filepath</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to compress a file that already exists somewhere on your server. +Supply a file path and the zip class will read it and add it to the archive:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$path</span> <span class="o">=</span> <span class="s1">'/path/to/photo.jpg'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">read_file</span><span class="p">(</span><span class="nv">$path</span><span class="p">);</span> + +<span class="c1">// Download the file to your desktop. Name it "my_backup.zip"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'my_backup.zip'</span><span class="p">);</span> +</pre></div> +</div> +<p>If you would like the Zip archive to maintain the directory structure of +the file in it, pass TRUE (boolean) in the second parameter. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$path</span> <span class="o">=</span> <span class="s1">'/path/to/photo.jpg'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">read_file</span><span class="p">(</span><span class="nv">$path</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> + +<span class="c1">// Download the file to your desktop. Name it "my_backup.zip"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'my_backup.zip'</span><span class="p">);</span> +</pre></div> +</div> +<p>In the above example, photo.jpg will be placed into the <em>path/to/</em> directory.</p> +<p>You can also specify a new name (path included) for the added file on the fly:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$path</span> <span class="o">=</span> <span class="s1">'/path/to/photo.jpg'</span><span class="p">;</span> +<span class="nv">$new_path</span> <span class="o">=</span> <span class="s1">'/new/path/some_photo.jpg'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">read_file</span><span class="p">(</span><span class="nv">$path</span><span class="p">,</span> <span class="nv">$new_path</span><span class="p">);</span> + +<span class="c1">// Download ZIP archive containing /new/path/some_photo.jpg</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'my_archive.zip'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::read_dir"> +<code class="descname">read_dir</code><span class="sig-paren">(</span><em>$path</em><span class="optional">[</span>, <em>$preserve_filepath = TRUE</em><span class="optional">[</span>, <em>$root_path = NULL</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::read_dir" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$path</strong> (<em>string</em>) – Path to directory</li> +<li><strong>$preserve_filepath</strong> (<em>bool</em>) – Whether to maintain the original path</li> +<li><strong>$root_path</strong> (<em>string</em>) – Part of the path to exclude from the archive directory</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Permits you to compress a directory (and its contents) that already exists somewhere on your server. +Supply a path to the directory and the zip class will recursively read and recreate it as a Zip archive. +All files contained within the supplied path will be encoded, as will any sub-directories contained within it. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$path</span> <span class="o">=</span> <span class="s1">'/path/to/your/directory/'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">read_dir</span><span class="p">(</span><span class="nv">$path</span><span class="p">);</span> + +<span class="c1">// Download the file to your desktop. Name it "my_backup.zip"</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'my_backup.zip'</span><span class="p">);</span> +</pre></div> +</div> +<p>By default the Zip archive will place all directories listed in the first parameter +inside the zip. If you want the tree preceding the target directory to be ignored, +you can pass FALSE (boolean) in the second parameter. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$path</span> <span class="o">=</span> <span class="s1">'/path/to/your/directory/'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">read_dir</span><span class="p">(</span><span class="nv">$path</span><span class="p">,</span> <span class="k">FALSE</span><span class="p">);</span> +</pre></div> +</div> +<p>This will create a ZIP with a directory named “directory” inside, then all sub-directories +stored correctly inside that, but will not include the <em>/path/to/your</em> part of the path.</p> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::archive"> +<code class="descname">archive</code><span class="sig-paren">(</span><em>$filepath</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::archive" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filepath</strong> (<em>string</em>) – Path to target zip archive</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +<p>Writes the Zip-encoded file to a directory on your server. Submit a valid server path +ending in the file name. Make sure the directory is writable (755 is usually OK). +Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">archive</span><span class="p">(</span><span class="s1">'/path/to/folder/myarchive.zip'</span><span class="p">);</span> <span class="c1">// Creates a file named myarchive.zip</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::download"> +<code class="descname">download</code><span class="sig-paren">(</span><em>$filename = 'backup.zip'</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::download" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>$filename</strong> (<em>string</em>) – Archive file name</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> +</td> +</tr> +</tbody> +</table> +<p>Causes the Zip file to be downloaded from your server. +You must pass the name you would like the zip file called. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'latest_stuff.zip'</span><span class="p">);</span> <span class="c1">// File will be named "latest_stuff.zip"</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Do not display any data in the controller in which you call +this method since it sends various server headers that cause the +download to happen and the file to be treated as binary.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::get_zip"> +<code class="descname">get_zip</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::get_zip" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Zip file content</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td> +</tr> +</tbody> +</table> +<p>Returns the Zip-compressed file data. Generally you will not need this method unless you +want to do something unique with the data. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="s1">'my_bio.txt'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="s1">'I was born in an elevator...'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> + +<span class="nv">$zip_file</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">get_zip</span><span class="p">();</span> +</pre></div> +</div> +</dd></dl> + +<dl class="method"> +<dt id="CI_Zip::clear_data"> +<code class="descname">clear_data</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Zip::clear_data" title="Permalink to this definition">¶</a></dt> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> +</tr> +</tbody> +</table> +<p>The Zip class caches your zip data so that it doesn’t need to recompile the Zip archive +for each method you use above. If, however, you need to create multiple Zip archives, +each with different data, you can clear the cache between calls. Example:</p> +<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="s1">'my_bio.txt'</span><span class="p">;</span> +<span class="nv">$data</span> <span class="o">=</span> <span class="s1">'I was born in an elevator...'</span><span class="p">;</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">add_data</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span> +<span class="nv">$zip_file</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">get_zip</span><span class="p">();</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">clear_data</span><span class="p">();</span> + +<span class="nv">$name</span> <span class="o">=</span> <span class="s1">'photo.jpg'</span><span class="p">;</span> +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">read_file</span><span class="p">(</span><span class="s2">"/path/to/photo.jpg"</span><span class="p">);</span> <span class="c1">// Read the file's contents</span> + +<span class="nv">$this</span><span class="o">-></span><span class="na">zip</span><span class="o">-></span><span class="na">download</span><span class="p">(</span><span class="s1">'myphotos.zip'</span><span class="p">);</span> +</pre></div> +</div> +</dd></dl> + +</dd></dl> + +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../database/index.html" class="btn btn-neutral float-right" title="Database Reference">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="xmlrpc.html" class="btn btn-neutral" title="XML-RPC and XML-RPC Server Classes"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2014 - 2019, British Columbia Institute of Technology. + Last updated on Sep 19, 2019. + </p> + </div> + + 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>. + +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'3.1.11', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: false + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html>
\ No newline at end of file |