From f964b16f3db95d655420dfae2012ee9fbb98a1a8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Nov 2013 17:04:55 +0200 Subject: Deprecate CI_Input::is_cli_request() and add common function is_cli() to replace it Calls to this function are often needed before the Input library is available --- user_guide_src/source/general/cli.rst | 2 +- user_guide_src/source/general/common_functions.rst | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst index 4145d5ccc..4f3b07d9e 100644 --- a/user_guide_src/source/general/cli.rst +++ b/user_guide_src/source/general/cli.rst @@ -23,7 +23,7 @@ but they are not always obvious. - Run your cron-jobs without needing to use *wget* or *curl* - Make your cron-jobs inaccessible from being loaded in the URL by - checking for ``$this->input->is_cli_request()`` + checking the return value of :func:`is_cli()`. - Make interactive "tasks" that can do things like set permissions, prune cache folders, run backups, etc. - Integrate with other applications in other languages. For example, a diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index e085ef808..2dfec9cc0 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -173,6 +173,19 @@ is_https() Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests). +is_cli() +======== + +.. php:function:: is_cli() + + :returns: bool + +Returns TRUE if the application is run through the command line +and FALSE if not. + +.. note:: This function checks both if the ``PHP_SAPI`` value is 'cli' + or if the ``STDIN`` constant is defined. + function_usable() ================= -- cgit v1.2.3-24-g4f1b