The number helper file contains some predefined function that deals with numeric data to display numbers in bytes format.

Load a Number Helper

You must load a number helper file in the controller to perform a number function in the CodeIgniter application.

Syntax

Function of Number Helper:

  1. byte_format(): As the name suggests, it is used to convert a large number into Bytes, KB, MB, GB and TB format.

Syntax

  • $num: It defines the number of bytes passed in the byte_format () function.
  • $precision: It defines the number of floating points can be precise in byte_format ().

Create a simple program of Number helper

Create a controller file Online.php and save it in application/controller folder. After that, write the following program in your controller file.

Online.php

When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/Online, it shows the output, as shown below.

CodeIgniter Number helper

Path Helper

The path helper file has some predefined functions that allow you to access the file path on the server.

Function of the Path helper

1.Set_realpath (): This function is used to set and access the file or directory path on the server without create of symbolic links. And if the file path is not existing, it shows an error message on the server.

Syntax

  • $path : It takes the path of a particular file or folder as a string that can access on the server.
  • $check_existance : If you want to show an error message on the server when a particular file or directory is not valid, you can use a Boolean value such as true or false.

Example:

Create a controller file Online.php and save it in application/controller/Online.php. After that, write the following program in your controller file.

Online.php

When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/Online, it shows the output, as shown below.

CodeIgniter Number helper

Pin It on Pinterest

Share This