Jump to content

public $load2;


maccy93

Recommended Posts

I'm learning MVC and getting a bit confused with the accessibility of variables in classes...

 

class Load {

public $load2;

}

 

Does this mean that the variable $load2 will be accessible just by all functions within the class Load?

or:

Does that mean that the variable $load2 will be accessible by all other classes, eg model, controller...etc inc all the functions within?

Link to comment
Share on other sites

Generally, "public" is a visibility keyword that tells a variable/method is accessible not just within the class nor by its subclasses, but can also be referenced outside the class, once an object of the class has been instantiated. If some other class is going to use it, it could possibly because the class is a subclass of that parent class that has the public variable, an object of that class was instantiated within the class using it, or the object referencing to that class was passed as a parameter in a method of the class using it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.