Thursday, November 13, 2014

Build-IN Functions


  • What is a function?
    • A function is a block of code that can reusable.
  • What is a build-in function?
    • PHP provides many functions that you can use to work with data. The functions are refered to as build-in functions.
  • Some of basic build-in function:
    • number-format($number[,$decimal]): this function return number that is formatted with a comma(,)
      • Exmple:$nf=number-format(12345)      //12.345
      • Example:$nf=number-format(12345,2) //12,345
    • date($format): this function return current date with specificed format string.
      • Example: $date=date('Y-m-d')   // 2014/13/11
    • Three functions for checking variable values.
      • isset($var): return true if the variable have been set and is not null value.
      • empty($var): return true if the variable hasn't been set ,contain null value or contain an empty string.
  • Build-in functions that you can use to pass control to another page.
    • As a PHP application executes, it moves from one web page to another. To do that, you can use the include and require function.
    • include($path):Insert and run the specified file. If function fail ,it cause a warning,that allow script to continue.
    • include_once($path): Same as the include function. But it make sure that the file include only once.
    • require($path): Works the same include function. However, if function fails it causes a fatal error that stop script.
    • require_once($path): Same as require function. But it make sure that the file include only once.
    • exit($status): Exits the current PHP script.

No comments:

Post a Comment