All Questions
4
questions
0
votes
5
answers
170
views
PHP5 member visibility
Could someone explain me, why is it possible to do the following in PHP, but, for example, not in C# or Java:
Class A {
protected $a = 'Howdy!';
}
Class B extends A {
public function howdy() ...
14
votes
4
answers
9k
views
Why does PHP allow protected and private methods to be made public via an override in subclasses?
From some brief fiddling about, I find I get an error when overriding superclass methods in a subclass when I do the following:
Override a protected superclass method with a private subclass method
...
44
votes
12
answers
2k
views
Why is the amount of visibility on methods and attributes important?
Why shouldn't one leave all methods and attributes accessible from anywhere (i.e. public)?
Can you give me an example of a problem I can run into if I declared an attribute as public?
0
votes
2
answers
150
views
Encapsulating and inheriting methods
I'm wondering if it's possible to encapsulate the methods of a class, but then expose them within a consuming class. For example (JFTR, I know this code is wrong)
class Consumer{
public ...