CodeIgniter - Common Functions
Common Functions
CodeIgniter
library
functions
and
helper
functions
need
to
be
initialized
before
they
are used but there are some common functions, which do not need to be initialized.
These common functions and their descriptions are given below.
Given below is an example, which demonstrates all of the above functions.
Example
Here
we
have
created
only
one
controller
in
which
we
will
use the
above
functions.
Copy the below given code and save it at application/controller/CommonFun_Controller.php.
<?php
class CommonFun_Controller
extends
CI_Controller
{
public function
index()
{
set_status_header(200); echo
is_php('5.3')."<br>";
var_dump(is_really_writable('./Form.php')); echo
config_item('language')."<br>";
echo remove_invisible_characters('This is a ‌test','UTF-
8')."<br>";
$str =
'<
This
>
is
\'
a
"
test
&
string'; echo
html_escape($str)."<br>";
echo "is_https():".var_dump(is_https())."<br>";
echo "is_cli():".var_dump(is_cli())."<br>"; var_dump(function_usable('test'))."<br>";
echo "get_mimes():".print_r(get_mimes())."<br>";
}
public function
test(){ echo
"Test
function";
}
}
?>
Change
the
routes.php file
at
application/config/routes.php
to
add
route
for
the
above controller and add the following line at the end of the file.
$route['commonfunctions']
=
'CommonFun_Controller';
Type the following URL in the address bar of your browser to execute the example.
Comments
Post a Comment