CodeIgniter4/general/common_functions.html
2022-04-09 00:27:21 +00:00

1147 lines
69 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Global Functions and Constants &mdash; CodeIgniter 4.1.9 documentation</title><link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" /><link rel="shortcut icon" href="../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script src="../_static/js/citheme.js"></script>
<script src="../_static/js/carbon.js"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Logging Information" href="logging.html" />
<link rel="prev" title="Helper Functions" href="helpers.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" style="background: #DD4814" >
<a href="../index.html"><img src="../_static/ci-logo-text.png" class="logo" alt="Logo"/>
</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="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intro/requirements.html">Server Requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intro/credits.html">Credits</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intro/psr.html">PSR Compliance</a></li>
<li class="toctree-l2"><a class="reference internal" href="../license.html">License Agreement</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../installation/installing_composer.html">Composer Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/installing_manual.html">Manual Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/running.html">Running Your App</a></li>
<li class="toctree-l2"><a class="reference internal" href="../changelogs/index.html">Change Logs</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>
<li class="toctree-l2"><a class="reference internal" href="../installation/repositories.html">CodeIgniter Repositories</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Build Your First Application</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="../concepts/index.html">CodeIgniter4 Overview</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../concepts/structure.html">Application Structure</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/mvc.html">Models, Views, and Controllers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/autoloader.html">Autoloading Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/services.html">Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/factories.html">Factories</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/http.html">Working With HTTP Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/security.html">Security Guidelines</a></li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">General Topics</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="configuration.html">Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="urls.html">CodeIgniter URLs</a></li>
<li class="toctree-l2"><a class="reference internal" href="helpers.html">Helper Functions</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Global Functions and Constants</a></li>
<li class="toctree-l2"><a class="reference internal" href="logging.html">Logging Information</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html">Error Handling</a></li>
<li class="toctree-l2"><a class="reference internal" href="caching.html">Web Page Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="ajax.html">AJAX Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html">Code Modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="managing_apps.html">Managing your Applications</a></li>
<li class="toctree-l2"><a class="reference internal" href="environments.html">Handling Multiple Environments</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../incoming/index.html">Controllers and Routing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../incoming/routing.html">URI Routing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/controllers.html">Controllers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/filters.html">Controller Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/message.html">HTTP Messages</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/request.html">Request Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/incomingrequest.html">IncomingRequest Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/content_negotiation.html">Content Negotiation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/methodspoofing.html">HTTP Method Spoofing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/restful.html">RESTful Resource Handling</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../outgoing/index.html">Building Responses</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/views.html">Views</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_cells.html">View Cells</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_renderer.html">View Renderer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_layouts.html">View Layouts</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_parser.html">View Parser</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_decorators.html">View Decorators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/table.html">HTML Table Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/response.html">HTTP Responses</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/api_responses.html">API Response Trait</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/localization.html">Localization</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Working With Databases</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/events.html">Database Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../models/index.html">Modeling Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../models/model.html">Using CodeIgniter's Model</a></li>
<li class="toctree-l2"><a class="reference internal" href="../models/entities.html">Using Entity Classes</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../dbmgmt/index.html">Managing Databases</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/forge.html">Database Manipulation with Database Forge</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/migration.html">Database Migrations</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/seeds.html">Database Seeding</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Library Reference</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/cookies.html">Cookies</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/curlrequest.html">CURLRequest Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Service</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/files.html">Working with Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/files.html#file-collections">File Collections</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/honeypot.html">Honeypot Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/images.html">Image Manipulation Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/publisher.html">Publisher</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/throttler.html">Throttler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/time.html">Times and Dates</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/uploaded_files.html">Working with Uploaded Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">Working with URIs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/validation.html">Validation</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/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/filesystem_helper.html">Filesystem 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/number_helper.html">Number 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/test_helper.html">Test 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/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>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html">Testing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../testing/overview.html">Getting Started</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/database.html">Database</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/fabricator.html">Generating Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/controllers.html">Controller Testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/feature.html">HTTP Testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/response.html">Testing Responses</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/benchmark.html">Benchmarking</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/debugging.html">Debugging Your Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/mocking.html">Mocking</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../cli/index.html">Command Line Usage</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli.html">Running via the Command Line</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_commands.html">Custom CLI Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_generators.html">CLI Generators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_library.html">CLI Library</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_request.html">CLIRequest Class</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../extending/index.html">Extending CodeIgniter</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../extending/core_classes.html">Creating Core System Classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/common.html">Replacing Common Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/events.html">Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/basecontroller.html">Extending the Controller</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/authentication.html">Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/contributing.html">Contributing to CodeIgniter</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" style="background: #DD4814" >
<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="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="index.html">General Topics</a> &raquo;</li>
<li>Global Functions and Constants</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="global-functions-and-constants">
<h1>Global Functions and Constants<a class="headerlink" href="#global-functions-and-constants" title="Permalink to this headline"></a></h1>
<p>CodeIgniter provides a few functions and variables that are globally defined, and are available to you at any point.
These do not require loading any additional libraries or helpers.</p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#global-functions" id="id1">Global Functions</a></p>
<ul>
<li><p><a class="reference internal" href="#service-accessors" id="id2">Service Accessors</a></p></li>
<li><p><a class="reference internal" href="#miscellaneous-functions" id="id3">Miscellaneous Functions</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#global-constants" id="id4">Global Constants</a></p>
<ul>
<li><p><a class="reference internal" href="#core-constants" id="id5">Core Constants</a></p></li>
<li><p><a class="reference internal" href="#time-constants" id="id6">Time Constants</a></p></li>
</ul>
</li>
</ul>
</div>
<section id="global-functions">
<h2><a class="toc-backref" href="#id1">Global Functions</a><a class="headerlink" href="#global-functions" title="Permalink to this headline"></a></h2>
<section id="service-accessors">
<h3><a class="toc-backref" href="#id2">Service Accessors</a><a class="headerlink" href="#service-accessors" title="Permalink to this headline"></a></h3>
<dl class="function">
<dt id="cache">
<code class="sig-name descname">cache</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">$key</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cache" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$key</strong> (<em>string</em>) The cache name of the item to retrieve from cache (Optional)</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Either the cache object, or the item retrieved from the cache</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>If no $key is provided, will return the Cache engine instance. If a $key
is provided, will return the value of $key as stored in the cache currently,
or null if no value is found.</p>
<p>Examples:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="nv">$foo</span> <span class="o">=</span> <span class="nx">cache</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">);</span>
<span class="nv">$cache</span> <span class="o">=</span> <span class="nx">cache</span><span class="p">();</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="cookie">
<code class="sig-name descname">cookie</code><span class="sig-paren">(</span><em class="sig-param">string $name</em><span class="optional">[</span>, <em class="sig-param">string $value = ''</em><span class="optional">[</span>, <em class="sig-param">array $options = []</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cookie" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$name</strong> (<em>string</em>) Cookie name</p></li>
<li><p><strong>$value</strong> (<em>string</em>) Cookie value</p></li>
<li><p><strong>$options</strong> (<em>array</em>) Cookie options</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">Cookie</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">Cookie</span></code> instance</p>
</dd>
<dt class="field-even">Throws</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">CookieException</span></code></p>
</dd>
</dl>
<p>Simpler way to create a new Cookie instance.</p>
</dd></dl>
<dl class="function">
<dt id="cookies">
<code class="sig-name descname">cookies</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">array $cookies = []</em><span class="optional">[</span>, <em class="sig-param">bool $getGlobal = true</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cookies" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$cookies</strong> (<em>array</em>) If <code class="docutils literal notranslate"><span class="pre">getGlobal</span></code> is <code class="docutils literal notranslate"><span class="pre">false</span></code>, this is passed to <code class="docutils literal notranslate"><span class="pre">CookieStore</span></code>s constructor.</p></li>
<li><p><strong>$getGlobal</strong> (<em>bool</em>) If <code class="docutils literal notranslate"><span class="pre">false</span></code>, creates a new instance of <code class="docutils literal notranslate"><span class="pre">CookieStore</span></code>.</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">CookieStore</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Instance of <code class="docutils literal notranslate"><span class="pre">CookieStore</span></code> saved in the current <code class="docutils literal notranslate"><span class="pre">Response</span></code>, or a new <code class="docutils literal notranslate"><span class="pre">CookieStore</span></code> instance.</p>
</dd>
</dl>
<p>Fetches the global <code class="docutils literal notranslate"><span class="pre">CookieStore</span></code> instance held by <code class="docutils literal notranslate"><span class="pre">Response</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="env">
<code class="sig-name descname">env</code><span class="sig-paren">(</span><em class="sig-param">$key</em><span class="optional">[</span>, <em class="sig-param">$default = null</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#env" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$key</strong> (<em>string</em>) The name of the environment variable to retrieve</p></li>
<li><p><strong>$default</strong> (<em>mixed</em>) The default value to return if no value is found.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The environment variable, the default value, or null.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>Used to retrieve values that have previously been set to the environment,
or return a default value if it is not found. Will format boolean values
to actual booleans instead of string representations.</p>
<p>Especially useful when used in conjunction with <strong>.env</strong> files for setting
values that are specific to the environment itself, like database
settings, API keys, etc.</p>
</dd></dl>
<dl class="function">
<dt id="esc">
<code class="sig-name descname">esc</code><span class="sig-paren">(</span><em class="sig-param">$data</em><span class="optional">[</span>, <em class="sig-param">$context = 'html'</em><span class="optional">[</span>, <em class="sig-param">$encoding</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#esc" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$data</strong> (<em>string|array</em>) The information to be escaped.</p></li>
<li><p><strong>$context</strong> (<em>string</em>) The escaping context. Default is html.</p></li>
<li><p><strong>$encoding</strong> (<em>string</em>) The character encoding of the string.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The escaped data.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>Escapes data for inclusion in web pages, to help prevent XSS attacks.
This uses the Laminas Escaper library to handle the actual filtering of the data.</p>
<p>If $data is a string, then it simply escapes and returns it.
If $data is an array, then it loops over it, escaping each value of the key/value pairs.</p>
<p>Valid context values: html, js, css, url, attr, raw</p>
</dd></dl>
<dl class="function">
<dt id="helper">
<code class="sig-name descname">helper</code><span class="sig-paren">(</span><em class="sig-param">$filename</em><span class="sig-paren">)</span><a class="headerlink" href="#helper" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$filename</strong> (<em>string|array</em>) The name of the helper file to load, or an array of names.</p></li>
</ul>
</dd>
</dl>
<p>Loads a helper file.</p>
<p>For full details, see the <a class="reference internal" href="helpers.html"><span class="doc">Helper Functions</span></a> page.</p>
</dd></dl>
<dl class="function">
<dt id="lang">
<code class="sig-name descname">lang</code><span class="sig-paren">(</span><em class="sig-param">$line</em><span class="optional">[</span>, <em class="sig-param">$args</em><span class="optional">[</span>, <em class="sig-param">$locale</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#lang" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$line</strong> (<em>string</em>) The line of text to retrieve</p></li>
<li><p><strong>$args</strong> (<em>array</em>) An array of data to substitute for placeholders.</p></li>
<li><p><strong>$locale</strong> (<em>string</em>) Specify a different locale to be used instead of default one.</p></li>
</ul>
</dd>
</dl>
<p>Retrieves a locale-specific file based on an alias string.</p>
<p>For more information, see the <a class="reference internal" href="../outgoing/localization.html"><span class="doc">Localization</span></a> page.</p>
</dd></dl>
<dl class="function">
<dt id="model">
<code class="sig-name descname">model</code><span class="sig-paren">(</span><em class="sig-param">$name</em><span class="optional">[</span>, <em class="sig-param">$getShared = true</em><span class="optional">[</span>, <em class="sig-param">&amp;$conn = null</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#model" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$name</strong> (<em>string</em>) </p></li>
<li><p><strong>$getShared</strong> (<em>boolean</em>) </p></li>
<li><p><strong>$conn</strong> (<em>ConnectionInterface|null</em>) </p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>More simple way of getting model instances</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="old">
<code class="sig-name descname">old</code><span class="sig-paren">(</span><em class="sig-param">$key</em><span class="optional">[</span>, <em class="sig-param">$default = null</em><span class="optional">[</span>, <em class="sig-param">$escape = 'html'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#old" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$key</strong> (<em>string</em>) The name of the old form data to check for.</p></li>
<li><p><strong>$default</strong> (<em>mixed</em>) The default value to return if $key doesnt exist.</p></li>
<li><p><strong>$escape</strong> (<em>mixed</em>) An <a class="reference external" href="#esc">escape</a> context or false to disable it.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The value of the defined key, or the default value.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>Provides a simple way to access “old input data” from submitting a form.</p>
<p>Example:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="c1">// in controller, checking form submittal</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span> <span class="nv">$model</span><span class="o">-&gt;</span><span class="na">save</span><span class="p">(</span><span class="nv">$user</span><span class="p">))</span> <span class="p">{</span>
<span class="c1">// &#39;withInput&#39; is what specifies &quot;old data&quot;</span>
<span class="c1">// should be saved.</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">back</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">withInput</span><span class="p">();</span>
<span class="p">}</span>
<span class="cp">?&gt;</span>
<span class="cm">&lt;!-- In your view file: --&gt;</span>
<span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;email&quot;</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;email&quot;</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">&lt;?</span><span class="o">=</span> <span class="nx">old</span><span class="p">(</span><span class="s1">&#39;email&#39;</span><span class="p">)</span> <span class="cp">?&gt;</span><span class="s">&quot;</span><span class="p">&gt;</span>
<span class="cm">&lt;!-- Or with arrays: --&gt;</span>
<span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;email&quot;</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;user[email]&quot;</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">&lt;?</span><span class="o">=</span> <span class="nx">old</span><span class="p">(</span><span class="s1">&#39;user.email&#39;</span><span class="p">)</span> <span class="cp">?&gt;</span><span class="s">&quot;</span><span class="p">&gt;</span>
</pre></div>
</div>
</dd></dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you are using the <a class="reference internal" href="../helpers/form_helper.html"><span class="doc">form helper</span></a>, this feature is built-in. You only
need to use this function when not using the form helper.</p>
</div>
<dl class="function">
<dt id="session">
<code class="sig-name descname">session</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">$key</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#session" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$key</strong> (<em>string</em>) The name of the session item to check for.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>An instance of the Session object if no $key, the value found in the session for $key, or null.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>Provides a convenient way to access the session class and to retrieve a
stored value. For more information, see the <a class="reference internal" href="../libraries/sessions.html"><span class="doc">Sessions</span></a> page.</p>
</dd></dl>
<dl class="function">
<dt id="timer">
<code class="sig-name descname">timer</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">$name</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#timer" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$name</strong> (<em>string</em>) The name of the benchmark point.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The Timer instance</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>CodeIgniterDebugTimer</p>
</dd>
</dl>
<p>A convenience method that provides quick access to the Timer class. You can pass in the name
of a benchmark point as the only parameter. This will start timing from this point, or stop
timing if a timer with this name is already running.</p>
<p>Example:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="c1">// Get an instance</span>
<span class="nv">$timer</span> <span class="o">=</span> <span class="nx">timer</span><span class="p">();</span>
<span class="c1">// Set timer start and stop points</span>
<span class="nx">timer</span><span class="p">(</span><span class="s1">&#39;controller_loading&#39;</span><span class="p">);</span> <span class="c1">// Will start the timer</span>
<span class="c1">// ...</span>
<span class="nx">timer</span><span class="p">(</span><span class="s1">&#39;controller_loading&#39;</span><span class="p">);</span> <span class="c1">// Will stop the running timer</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="view">
<code class="sig-name descname">view</code><span class="sig-paren">(</span><em class="sig-param">$name</em><span class="optional">[</span>, <em class="sig-param">$data</em><span class="optional">[</span>, <em class="sig-param">$options</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#view" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$name</strong> (<em>string</em>) The name of the file to load</p></li>
<li><p><strong>$data</strong> (<em>array</em>) An array of key/value pairs to make available within the view.</p></li>
<li><p><strong>$options</strong> (<em>array</em>) An array of options that will be passed to the rendering class.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The output from the view.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>string</p>
</dd>
</dl>
<p>Grabs the current RendererInterface-compatible class
and tells it to render the specified view. Simply provides
a convenience method that can be used in Controllers,
libraries, and routed closures.</p>
<p>Currently, these options are available for use within the <code class="docutils literal notranslate"><span class="pre">$options</span></code> array:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">saveData</span></code> specifies that data will persistent between multiple calls to <code class="docutils literal notranslate"><span class="pre">view()</span></code> within the same request. If you do not want the data to be persisted, specify false.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cache</span></code> specifies the number of seconds to cache the view for. See <a class="reference internal" href="../outgoing/views.html#caching-views"><span class="std std-ref">Caching Views</span></a> for the details.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">debug</span></code> can be set to false to disable the addition of debug code for <a class="reference internal" href="../testing/debugging.html#the-debug-toolbar"><span class="std std-ref">Debug Toolbar</span></a>.</p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">$option</span></code> array is provided primarily to facilitate third-party integrations with
libraries like Twig.</p>
<p>Example:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="nv">$data</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;user&#39;</span> <span class="o">=&gt;</span> <span class="nv">$user</span><span class="p">];</span>
<span class="k">echo</span> <span class="nx">view</span><span class="p">(</span><span class="s1">&#39;user_profile&#39;</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span>
</pre></div>
</div>
<p>For more details, see the <a class="reference internal" href="../outgoing/views.html"><span class="doc">Views</span></a> page.</p>
</dd></dl>
<dl class="function">
<dt id="view_cell">
<code class="sig-name descname">view_cell</code><span class="sig-paren">(</span><em class="sig-param">$library</em><span class="optional">[</span>, <em class="sig-param">$params = null</em><span class="optional">[</span>, <em class="sig-param">$ttl = 0</em><span class="optional">[</span>, <em class="sig-param">$cacheName = null</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#view_cell" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$library</strong> (<em>string</em>) </p></li>
<li><p><strong>$params</strong> (<em>null</em>) </p></li>
<li><p><strong>$ttl</strong> (<em>integer</em>) </p></li>
<li><p><strong>$cacheName</strong> (<em>string|null</em>) </p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>View cells are used within views to insert HTML chunks that are managed by other classes.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>string</p>
</dd>
</dl>
<p>For more details, see the <a class="reference internal" href="../outgoing/view_cells.html"><span class="doc">View Cells</span></a> page.</p>
</dd></dl>
</section>
<section id="miscellaneous-functions">
<h3><a class="toc-backref" href="#id3">Miscellaneous Functions</a><a class="headerlink" href="#miscellaneous-functions" title="Permalink to this headline"></a></h3>
<dl class="function">
<dt id="app_timezone">
<code class="sig-name descname">app_timezone</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#app_timezone" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The timezone the application has been set to display dates in.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns the timezone the application has been set to display dates in.</p>
</dd></dl>
<dl class="function">
<dt id="csp_script_nonce">
<code class="sig-name descname">csp_script_nonce</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csp_script_nonce" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The CSP nonce attribute for script tag.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns the nonce attribute for a script tag. For example: <code class="docutils literal notranslate"><span class="pre">nonce=&quot;Eskdikejidojdk978Ad8jf&quot;</span></code>.
See <a class="reference internal" href="../outgoing/response.html#content-security-policy"><span class="std std-ref">Content Security Policy</span></a>.</p>
</dd></dl>
<dl class="function">
<dt id="csp_style_nonce">
<code class="sig-name descname">csp_style_nonce</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csp_style_nonce" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The CSP nonce attribute for style tag.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns the nonce attribute for a style tag. For example: <code class="docutils literal notranslate"><span class="pre">nonce=&quot;Eskdikejidojdk978Ad8jf&quot;</span></code>.
See <a class="reference internal" href="../outgoing/response.html#content-security-policy"><span class="std std-ref">Content Security Policy</span></a>.</p>
</dd></dl>
<dl class="function">
<dt id="csrf_token">
<code class="sig-name descname">csrf_token</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csrf_token" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The name of the current CSRF token.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns the name of the current CSRF token.</p>
</dd></dl>
<dl class="function">
<dt id="csrf_header">
<code class="sig-name descname">csrf_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csrf_header" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The name of the header for current CSRF token.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>The name of the header for current CSRF token.</p>
</dd></dl>
<dl class="function">
<dt id="csrf_hash">
<code class="sig-name descname">csrf_hash</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csrf_hash" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The current value of the CSRF hash.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns the current CSRF hash value.</p>
</dd></dl>
<dl class="function">
<dt id="csrf_field">
<code class="sig-name descname">csrf_field</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csrf_field" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A string with the HTML for hidden input with all required CSRF information.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns a hidden input with the CSRF information already inserted:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;hidden&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;{csrf_token}&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;{csrf_hash}&quot;</span><span class="o">&gt;</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="csrf_meta">
<code class="sig-name descname">csrf_meta</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#csrf_meta" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A string with the HTML for meta tag with all required CSRF information.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>string</p>
</dd>
</dl>
<p>Returns a meta tag with the CSRF information already inserted:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">meta</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;{csrf_header}&quot;</span> <span class="nx">content</span><span class="o">=</span><span class="s2">&quot;{csrf_hash}&quot;</span><span class="o">&gt;</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="force_https">
<code class="sig-name descname">force_https</code><span class="sig-paren">(</span><em class="sig-param">$duration = 31536000</em><span class="optional">[</span>, <em class="sig-param">$request = null</em><span class="optional">[</span>, <em class="sig-param">$response = null</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#force_https" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$duration</strong> (<em>int</em>) The number of seconds browsers should convert links to this resource to HTTPS.</p></li>
<li><p><strong>$request</strong> (<em>RequestInterface</em>) An instance of the current Request object.</p></li>
<li><p><strong>$response</strong> (<em>ResponseInterface</em>) An instance of the current Response object.</p></li>
</ul>
</dd>
</dl>
<p>Checks to see if the page is currently being accessed via HTTPS. If it is, then
nothing happens. If it is not, then the user is redirected back to the current URI
but through HTTPS. Will set the HTTP Strict Transport Security header, which instructs
modern browsers to automatically modify any HTTP requests to HTTPS requests for the $duration.</p>
</dd></dl>
<dl class="function">
<dt id="function_usable">
<code class="sig-name descname">function_usable</code><span class="sig-paren">(</span><em class="sig-param">$function_name</em><span class="sig-paren">)</span><a class="headerlink" href="#function_usable" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$function_name</strong> (<em>string</em>) Function to check for</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>true if the function exists and is safe to call, false otherwise.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="is_cli">
<code class="sig-name descname">is_cli</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#is_cli" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>true if the script is being executed from the command line or false otherwise.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="is_really_writable">
<code class="sig-name descname">is_really_writable</code><span class="sig-paren">(</span><em class="sig-param">$file</em><span class="sig-paren">)</span><a class="headerlink" href="#is_really_writable" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$file</strong> (<em>string</em>) The filename being checked.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>true if you can write to the file, false otherwise.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="log_message">
<code class="sig-name descname">log_message</code><span class="sig-paren">(</span><em class="sig-param">$level</em>, <em class="sig-param">$message</em><span class="optional">[</span>, <em class="sig-param">$context</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#log_message" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$level</strong> (<em>string</em>) The level of severity</p></li>
<li><p><strong>$message</strong> (<em>string</em>) The message that is to be logged.</p></li>
<li><p><strong>$context</strong> (<em>array</em>) An associative array of tags and their values that should be replaced in $message</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>true if was logged successfully or false if there was a problem logging it</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
<p>Logs a message using the Log Handlers defined in <strong>app/Config/Logger.php</strong>.</p>
<p>Level can be one of the following values: <strong>emergency</strong>, <strong>alert</strong>, <strong>critical</strong>, <strong>error</strong>, <strong>warning</strong>,
<strong>notice</strong>, <strong>info</strong>, or <strong>debug</strong>.</p>
<p>Context can be used to substitute values in the message string. For full details, see the
<a class="reference internal" href="logging.html"><span class="doc">Logging Information</span></a> page.</p>
</dd></dl>
<dl class="function">
<dt id="redirect">
<code class="sig-name descname">redirect</code><span class="sig-paren">(</span><em class="sig-param">string $route</em><span class="sig-paren">)</span><a class="headerlink" href="#redirect" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$route</strong> (<em>string</em>) The reverse-routed or named route to redirect the user to.</p></li>
</ul>
</dd>
</dl>
<p>Returns a RedirectResponse instance allowing you to easily create redirects:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="c1">// Go back to the previous page</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">back</span><span class="p">();</span>
<span class="c1">// Go to specific URI</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">to</span><span class="p">(</span><span class="s1">&#39;/admin&#39;</span><span class="p">);</span>
<span class="c1">// Go to a named route</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">route</span><span class="p">(</span><span class="s1">&#39;named_route&#39;</span><span class="p">);</span>
<span class="c1">// Keep the old input values upon redirect so they can be used by the `old()` function</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">back</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">withInput</span><span class="p">();</span>
<span class="c1">// Set a flash message</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">back</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">with</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="s1">&#39;message&#39;</span><span class="p">);</span>
<span class="c1">// Copies all cookies from global response instance</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">back</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">withCookies</span><span class="p">();</span>
<span class="c1">// Copies all headers from the global response instance</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">back</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">withHeaders</span><span class="p">();</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">redirect()-&gt;back()</span></code> is not the same as browser “back” button.
It takes a visitor to “the last page viewed during the Session” when the Session is available.
If the Session hasnt been loaded, or is otherwise unavailable, then a sanitized version of HTTP_REFERER will be used.</p>
</div>
<p>When passing an argument into the function, it is treated as a named/reverse-routed route, not a relative/full URI,
treating it the same as using <code class="docutils literal notranslate"><span class="pre">redirect()-&gt;route()</span></code>:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="c1">// Go to a named/reverse-routed URI</span>
<span class="k">return</span> <span class="nx">redirect</span><span class="p">(</span><span class="s1">&#39;named_route&#39;</span><span class="p">);</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="remove_invisible_characters">
<code class="sig-name descname">remove_invisible_characters</code><span class="sig-paren">(</span><em class="sig-param">$str</em><span class="optional">[</span>, <em class="sig-param">$urlEncoded = true</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#remove_invisible_characters" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$str</strong> (<em>string</em>) Input string</p></li>
<li><p><strong>$urlEncoded</strong> (<em>bool</em>) Whether to remove URL-encoded characters as well</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Sanitized string</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>string</p>
</dd>
</dl>
<p>This function prevents inserting null characters between ASCII
characters, like Java\0script.</p>
<p>Example:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="nx">remove_invisible_characters</span><span class="p">(</span><span class="s1">&#39;Java\\0script&#39;</span><span class="p">);</span>
<span class="c1">// Returns: &#39;Javascript&#39;</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="route_to">
<code class="sig-name descname">route_to</code><span class="sig-paren">(</span><em class="sig-param">$method</em><span class="optional">[</span>, <em class="sig-param">...$params</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#route_to" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$method</strong> (<em>string</em>) The named route alias, or name of the controller/method to match.</p></li>
<li><p><strong>$params</strong> (<em>mixed</em>) One or more parameters to be passed to be matched in the route.</p></li>
</ul>
</dd>
</dl>
<p>Generates a URI relative to the domain name (not <strong>baseUrl</strong>) for you based on either a named route alias,
or a controller::method combination. Will take parameters into effect, if provided.</p>
<p>For full details, see the <a class="reference internal" href="../incoming/routing.html"><span class="doc">URI Routing</span></a> page.</p>
</dd></dl>
<dl class="function">
<dt id="service">
<code class="sig-name descname">service</code><span class="sig-paren">(</span><em class="sig-param">$name</em><span class="optional">[</span>, <em class="sig-param">...$params</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#service" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$name</strong> (<em>string</em>) The name of the service to load</p></li>
<li><p><strong>$params</strong> (<em>mixed</em>) One or more parameters to pass to the service method.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>An instance of the service class specified.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>Provides easy access to any of the <a class="reference internal" href="../concepts/services.html"><span class="doc">Services</span></a> defined in the system.
This will always return a shared instance of the class, so no matter how many times this is called
during a single request, only one class instance will be created.</p>
<p>Example:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="nv">$logger</span> <span class="o">=</span> <span class="nx">service</span><span class="p">(</span><span class="s1">&#39;logger&#39;</span><span class="p">);</span>
<span class="nv">$renderer</span> <span class="o">=</span> <span class="nx">service</span><span class="p">(</span><span class="s1">&#39;renderer&#39;</span><span class="p">,</span> <span class="nx">APPPATH</span> <span class="o">.</span> <span class="s1">&#39;views/&#39;</span><span class="p">);</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="single_service">
<code class="sig-name descname">single_service</code><span class="sig-paren">(</span><em class="sig-param">$name</em><span class="optional">[</span>, <em class="sig-param">...$params</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#single_service" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$name</strong> (<em>string</em>) The name of the service to load</p></li>
<li><p><strong>$params</strong> (<em>mixed</em>) One or more parameters to pass to the service method.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>An instance of the service class specified.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>mixed</p>
</dd>
</dl>
<p>Identical to the <strong>service()</strong> function described above, except that all calls to this
function will return a new instance of the class, where <strong>service</strong> returns the same
instance every time.</p>
</dd></dl>
<dl class="function">
<dt id="slash_item">
<code class="sig-name descname">slash_item</code><span class="sig-paren">(</span><em class="sig-param">$item</em><span class="sig-paren">)</span><a class="headerlink" href="#slash_item" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$item</strong> (<em>string</em>) Config item name</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The configuration item or null if the item doesnt exist</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>string|null</p>
</dd>
</dl>
<p>Fetch a config file item with slash appended (if not empty)</p>
</dd></dl>
<dl class="function">
<dt id="stringify_attributes">
<code class="sig-name descname">stringify_attributes</code><span class="sig-paren">(</span><em class="sig-param">$attributes</em><span class="optional">[</span>, <em class="sig-param">$js</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#stringify_attributes" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>$attributes</strong> (<em>mixed</em>) string, array of key value pairs, or object</p></li>
<li><p><strong>$js</strong> (<em>boolean</em>) true if values do not need quotes (Javascript-style)</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>String containing the attribute key/value pairs, comma-separated</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>string</p>
</dd>
</dl>
<p>Helper function used to convert a string, array, or object of attributes to a string.</p>
</dd></dl>
</section>
</section>
<section id="global-constants">
<h2><a class="toc-backref" href="#id4">Global Constants</a><a class="headerlink" href="#global-constants" title="Permalink to this headline"></a></h2>
<p>The following constants are always available anywhere within your application.</p>
<section id="core-constants">
<h3><a class="toc-backref" href="#id5">Core Constants</a><a class="headerlink" href="#core-constants" title="Permalink to this headline"></a></h3>
<dl class="const">
<dt id="APPPATH">
<em class="property">constant </em><code class="sig-name descname">APPPATH</code><a class="headerlink" href="#APPPATH" title="Permalink to this definition"></a></dt>
<dd><p>The path to the <strong>app</strong> directory.</p>
</dd></dl>
<dl class="const">
<dt id="ROOTPATH">
<em class="property">constant </em><code class="sig-name descname">ROOTPATH</code><a class="headerlink" href="#ROOTPATH" title="Permalink to this definition"></a></dt>
<dd><p>The path to the project root directory. Just above <code class="docutils literal notranslate"><span class="pre">APPPATH</span></code>.</p>
</dd></dl>
<dl class="const">
<dt id="SYSTEMPATH">
<em class="property">constant </em><code class="sig-name descname">SYSTEMPATH</code><a class="headerlink" href="#SYSTEMPATH" title="Permalink to this definition"></a></dt>
<dd><p>The path to the <strong>system</strong> directory.</p>
</dd></dl>
<dl class="const">
<dt id="FCPATH">
<em class="property">constant </em><code class="sig-name descname">FCPATH</code><a class="headerlink" href="#FCPATH" title="Permalink to this definition"></a></dt>
<dd><p>The path to the directory that holds the front controller.</p>
</dd></dl>
<dl class="const">
<dt id="WRITEPATH">
<em class="property">constant </em><code class="sig-name descname">WRITEPATH</code><a class="headerlink" href="#WRITEPATH" title="Permalink to this definition"></a></dt>
<dd><p>The path to the <strong>writable</strong> directory.</p>
</dd></dl>
</section>
<section id="time-constants">
<h3><a class="toc-backref" href="#id6">Time Constants</a><a class="headerlink" href="#time-constants" title="Permalink to this headline"></a></h3>
<dl class="const">
<dt id="SECOND">
<em class="property">constant </em><code class="sig-name descname">SECOND</code><a class="headerlink" href="#SECOND" title="Permalink to this definition"></a></dt>
<dd><p>Equals 1.</p>
</dd></dl>
<dl class="const">
<dt id="MINUTE">
<em class="property">constant </em><code class="sig-name descname">MINUTE</code><a class="headerlink" href="#MINUTE" title="Permalink to this definition"></a></dt>
<dd><p>Equals 60.</p>
</dd></dl>
<dl class="const">
<dt id="HOUR">
<em class="property">constant </em><code class="sig-name descname">HOUR</code><a class="headerlink" href="#HOUR" title="Permalink to this definition"></a></dt>
<dd><p>Equals 3600.</p>
</dd></dl>
<dl class="const">
<dt id="DAY">
<em class="property">constant </em><code class="sig-name descname">DAY</code><a class="headerlink" href="#DAY" title="Permalink to this definition"></a></dt>
<dd><p>Equals 86400.</p>
</dd></dl>
<dl class="const">
<dt id="WEEK">
<em class="property">constant </em><code class="sig-name descname">WEEK</code><a class="headerlink" href="#WEEK" title="Permalink to this definition"></a></dt>
<dd><p>Equals 604800.</p>
</dd></dl>
<dl class="const">
<dt id="MONTH">
<em class="property">constant </em><code class="sig-name descname">MONTH</code><a class="headerlink" href="#MONTH" title="Permalink to this definition"></a></dt>
<dd><p>Equals 2592000.</p>
</dd></dl>
<dl class="const">
<dt id="YEAR">
<em class="property">constant </em><code class="sig-name descname">YEAR</code><a class="headerlink" href="#YEAR" title="Permalink to this definition"></a></dt>
<dd><p>Equals 31536000.</p>
</dd></dl>
<dl class="const">
<dt id="DECADE">
<em class="property">constant </em><code class="sig-name descname">DECADE</code><a class="headerlink" href="#DECADE" title="Permalink to this definition"></a></dt>
<dd><p>Equals 315360000.</p>
</dd></dl>
</section>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="helpers.html" class="btn btn-neutral float-left" title="Helper Functions" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="logging.html" class="btn btn-neutral float-right" title="Logging Information" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2019-2022 CodeIgniter Foundation.
<span class="lastupdated">Last updated on Apr 09, 2022.
</span></p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(false);
});
</script>
</body>
</html>