PHP – Function

Tram Ho

1) Function:

A function is a block of statements that can be used repeatedly in a program

A function will not be executed automatically on page load

A function will be executed by a function call

Syntax :

Arguments in the function (Arguments):

In a function we can call arguments to perform tasks and actions in functions

For example:

The function has 1 argument:

The function has 2 arguments:

Returning values:

To have a function return a value, use a return statement

For example:

2) Function available in PHP:

In PHP, there are many functions available to use that make coding quick and easy

The date () function:

Definition: Format a local date and time and return a formatted date string



Y: year,

m: month,

d: date,

H: hour,

i: minutes,

s: seconds

For example:

This is the time taken on the server, not the real time.

The date () function combines with the function date_default_timezone_set (“Asia / Bangkok”) to properly format the current location.

For example:

The date () function combines with many functions to change the time as desired by the user.

Use the function: strtotime () to change the time.

For example:

3) Documentation:

Share the news now

Source : Viblo