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
https://forums.phpfreaks.com/topic/253010-public-load2/
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
https://forums.phpfreaks.com/topic/253010-public-load2/#findComment-1297159
Share on other sites

Do you ever heard about helps? Go to php.net/manual/en, here you'll find a lot of information. For example, read about visibility of class's variables: http://www.php.net/manual/en/language.oop5.visibility.php

 

Here you can find descriptions of public, protected and private properties.

Link to comment
https://forums.phpfreaks.com/topic/253010-public-load2/#findComment-1297160
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.