All Questions
Tagged with visibility php
142
questions
135
votes
6
answers
38k
views
Default visibility of class methods in PHP
I looked at the manual, but I can't seem to find the answer.
What is the default visibility in PHP for methods without a visibility declaration? Does PHP have a package visibility like in Java?
...
7
votes
2
answers
8k
views
Method accessing protected property of another object of the same class
Should an object's method be able to access a protected property of another object of the same class?
I'm coding in PHP, and I just discovered that an object's protected property is allowed to be ...
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 ...
3
votes
3
answers
563
views
PHP Scope and Class Instance Interaction
It seems as though different instances of a class can know about each others' private member variables.
I have provided some code that attempts to showcase my issue, and I will try to explain it.
We ...
1
vote
3
answers
2k
views
Setters/Getters, Visibility [ OOP ] in PHP
I'm in the process of reformatting my class ( seen below ) - I think I made the mistake of setting everything with the same visibility in my class, whereas properties should really be private and ...
1
vote
3
answers
1k
views
PHP print_r and static member
I've got an instance of a DB object that's passed to a Session object, because the Session object has several methods that make use of DB object to execute SQL statements I had plan to store this DB ...
23
votes
2
answers
6k
views
__destruct visibility for PHP
Should the "visibility" for the __destruct() function be public or something else? I'm trying to write a standards doc for my group and this question came up.