The ->
means that you are calling a method from an object. One object is just one instance of a class and a class is just a definition of a type. Classes are the fundamental building blocks of Object Oriented Programming. When you create a class you are abstracting a concept: defining what some concept is in your application.
This definition contains both behaviors and properties. For instance, when you create a class user, one possible behavior of users is to create a new account and one possible property is the username.
In PHP behaviors are implemented as functions inside objects. Just to make distinction clear from functions outside objects we call those special functions methods. So when you define a class user inside of it you create a function create_account
which represents the behavior of the user in creating one account in the system.
When you have a class User
in php you create objects of this class (variables of type User
) by the following syntax $user = new User();
and some parameters can be passed to construct the object (read about constructors). Then, having the object $user
you can access its behaviors and properties by the ->
syntax.
In that case, $user->create_account($username, $password)
calls the method create_account
of the User
type passing the right parameters.