PHP Methods
PHP Methods
Methods are function or procedures declared by the developer, that helps when applying the routines. Using methods in the applications allows to reuse your code throughout the application, optimizing the development experience.
Creating a new method
- Give the method a name and click Create. As in the image below.
PHP methods are incorporated into the same class, so it is not possible to use two functions with the same name even when used in different methods.
- Methods can receive parameters.
- Add the amount of variables:
-
Defining the variables:
- Name : Type in the variable’s name.
- Type : Selecting the type of variables: For Value or For Reference.
- Value Standard : The parameter’s value used to initialize when calling the method.
References allows to create a second name for a variable that you can use to read and modify the variable’s original information.
- Editing a parameter:
- : Checking all the parameters in the parameter list.
- : Uncheck all the parameters in the parameter list.
- : Edit the selected parameter of the list.
- : Deletes the selected variable of the list.