August 13, 2017

Core PHP: User-Defined Functions (6.1)

Functions


In the example below, we create the function sayHello(). The opening curly brace ({) indicates that this is the beginning of the function code, while the closing curly brace (}) indicates that this is the end.
To call the function, just write its name:
function sayHello() {
  echo "Hello!";
}

sayHello(); //call the function

//Outputs "Hello!"

No comments:

Post a Comment