Defining Functions in PHP, How to Define a Function in PHP, Codecademy Learn PHP, Create A Function

In this PHP coding lesson, we take a look at Defining Functions in PHP, How to Define a Function in PHP, Codecademy Learn PHP, Create A Function. This is based on the “Introduction to PHP Functions” section in the course, “Learn PHP” on Codecademy. In this lesson, we learn how about defining functions in PHP. Learning how to define a function in PHP is the first step to understanding PHP functions. We learn that we use the function keyword when we start our function definition. After using the function keyword, we then name our function. Functions must begin with a letter or also an underscore. A function may be followed by any letter, number, or underscore. We then create a code block using curly brackets. Whatever code is inside the code block will be executed whenever we invoke the function. Once we have a defined function, we are able to invoke our function as many times as we want. We will be able to run the code within the code block, without having to copy or paste, or retype any code, only the function invocation. When naming a function, the naming convention is using camelCase. This is in opposition to variable names which use snake_case. Make sure your function describes what the function does. Thanks for watching Defining Functions in PHP, How to Define a Function in PHP, Codecademy Learn PHP, Create A Function. We will cover invoking functions in the next lesson!