473,854 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php 5 classes: public, protected and private

Hi,

finally giving php 5 a go, and going over the new approach to classes.
Can someone clarify the public, private and protected to me?

I quote the php manual: "The visibility of a property or method can be
defined by prefixing the declaration with the keywords: public,
protected or private. Public declared items can be accessed
everywhere."

But should I read "...can be accessed everywhere within a given class."
or "...can be accessed by all other classes." ?

Job

Nov 27 '06
86 4683

"Moot" <mo************ *******@yahoo.c omwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Tony Marston wrote:
>"Michael Fesser" <ne*****@gmx.de wrote in message
news:41******* *************** **********@4ax. com...
.oO(Tony Marston)

This is a PHP newsgroup, so I am explaining how interfaces work within
PHP.

OK, please do that, no empty promises. Please explain, what interfaces
in PHP are and what you can do with them. Or can't do. I'm listening!

Micha

It is a simple argument. In PHP interfaces are optional. I *do not* have
to
define an interface before I can access a method in an object. The fact
that
interfaces may have their uses in specialised circumstances does not get
away from the fact that under normal use they are optional.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

- Interfaces are optional, you don't need to use them to access class
functions.
- Classes are optional, you don't need to define them to use functions
and have reusable code.
- High level languages are optional, you don't need to use them to
access the computer's registers and memory
- All programming languages are optional, you can just write the
machine code directly

Optional != Useless

The whole point of all of these languages, paradigms, and concepts we
have available to us isn't to force you to use them, it's to make the
trivial details disappear so you can focus at a higher level and more
abstract ideas. If you don't want to use them, that's your choice, but
they wouldn't exist if lots of people didn't find them useful.
Some people may find them useful, whie others have no use for them at all.
It is a matter of choice.
And if the point you're trying to argue is merely that interfaces are
optional, then I think that's a very silly argument to make.
It is a perfectly valid argument against the idea that because interfaces
are there you MUST use them.
Yes, PHP
doesn't *force* you to use interfaces. You win that point.
Good. That was the only point I was making.
Way to go.
Next up: I claim that the sky is sometimes blue.
And your point is?

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Dec 5 '06 #71

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:hu******** *************** *******@comcast .com...
Tony Marston wrote:
>Why is it so difficult for you to accept that YOUR opinion is not the
ONLY opinion that is allowed to exist? Just because you can quote some
people who agree with you does not make you right. I have quoted from
other sources who agree with me, yet you dismiss all these different
opinions as being "irrelevant ".

Your use of personal insults also shows what a juvenile mind you have.

Why is it so difficult for you to understand that you, with no real OO
experience,
Rubbish. I have been writing OO software that works for 4 years.
and in direct conflict with industry-recognized experts such as Booch,
Jacobson and Rumbaugh, as well as virtually every college level course on
the country, are full of shit?
There is no such thing as one set of experts with whom EVERYBODY agrees.
There are lots of people with lots of conflicting opinions. I happen to
disagee with your opinions, and I have quoted other people who also
disagree.
Because you're stoopid, that's why.

And the insults are because you are too stoopid to understand anything
else, Tony.

People around here are laughing at you. Your stoopidity is beyond
comprehension by anyone with any intellect.
Your juvenile insults show just how small minded you really are.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Dec 5 '06 #72
This is a PHP newsgroup, not an OO newsgroup, so the discussion of
interfaces concerns PHP, and in PHP interfaces are optional and unnecessary.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:hu******** *************** *******@comcast .com...
Tony Marston wrote:
>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:v8******* *************** ********@comcas t.com...
>>>Tony Marston wrote:

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:4q**** *************** ***********@com cast.com...
>Tony Marston wrote:
<snip>

>>This is a PHP newsgroup, so I am explaining how interfaces work within
>>PHP. It is a simple fact that interfaces ARE NOT NECESSARY in PHP. The
>>fact that interfaces are treated differently in other languages is
>>totally irrelevant. The fact that YOU think that interfaces in PHP
>>should behave exactly the same as in other languages is also
>>irrelevan t.
>>
>
>The subject of interfaces came up in the OO context, not a PHP
>interfac e.
>
>However, you're too stupid to understand there's a difference between
>the two. So you keep trying to change the subject then justifying your
>change - just like any troll.
This is a PHP newsgroup. All my arguments concern PHP. I do not care
that other languages have different implementations because that is
totally irrelevant. The simple fact is that in PHP it is not necessary
to use interfaces.
This discussion has to do with interfaces in the OO context. They are
not the same as PHP interfaces.

But you're too stoopid to understand the difference, so like a troll you
try to change the subject.

Go away, troll.


I am not changing the subject, you are. This is a PHP newsgroup, and my
argument is simply that interfaces are not necessary in PHP. You cannot
disprove this argument, so you attempt to change it to a different
argument.

Sorry, Tony. You're even too stoopid to understand the difference between
interfaces in the OO context, which is where this started out, and the PHP
interface keyword.

So you try to change the subject to something else you know absolutely
nothing about, then accuse others of doing the same.

Go back through this thread. Everyone was talking about OO interfaces
before troll Tony Marston stuck his big (and stoopid) mouth in here.

But then you didn't understand the difference the first time; you'll be
too stoopid to understand the difference the second time, also.

People are laughing at you, Tony.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Dec 5 '06 #73

"Michael Fesser" <ne*****@gmx.de wrote in message
news:4u******** *************** *********@4ax.c om...
.oO(Jerry Stuckle)
>>You notice how Tony refuses to answer your question?

Yep.
>>I'm wondering - does the term megalomaniac ring a bell? Or do you think
it's just that he's beyond stoopid?

I don't know, but actually I don't really care at all. He has just
proven that any attempt to further discuss these things doesn't make
sense. He is always right, the rest of the world is wrong.
I am not wrong. I have made two simple statements that you cannot disprove:

(a) In PHP interfaces are not necessary.
(b) Enapsulation does not mean that all variables must be declared private
or protected.

What's so difficult to understand about that?

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Dec 5 '06 #74

"Curtis" <dy****@gmail.c omwrote in message
news:11******** **************@ 16g2000cwy.goog legroups.com...
Tony Marston wrote:
>No, encapsulation is not about making everything private, it is about
putting data and the operations which act upon that data into a single
class. The ability to make certain operations or pieces of data private
or
protected is OPTIONAL, not MANDATORY.

I never claimed to summarize the entirety of encapsulation as the act
of making EVERYTHING private, I was merely restating in my own words to
try and clarify my understanding.
>I am not saying that you MUST NOT make things private/protected, I am
simply
arguing against the statement that you MUST use the private/protected
option. The point is that his is entirely OPTIONAL and is a matter of
personal preference.

You seem to be best friends with the straw man fallacy.
So do otherpeople in this newsgroup.
>As for saying that you MUST make all data private and access it through
getters and setters, you obviously haven't read
http://www.javaworld.com/javaworld/j...5-toolbox.html

The sources I've gathered, although differ slightly in diction,
generally concur on the meaning of encapsulation
Not everybody agrees on what encapsulation is. Not everybody agrees on what
OO is. For every opinion there is a different opinion. Some features are
optional, so it is a matter of personal preference whether to use them or
not.
>. It is true that not
all experts in a field will agree on everything, but the areas in which
there is genuine knowledge are not up for debate or subject to opinion.
I disagree. Absolutely everything is open to debate and subject to different
opinions.
You may be confusing semantics for the actual act of implementation, in
this case.

Please don't put words in my mouth. I never said that you MUST do
anything. Honestly, the source you cited is extremely dubious. Nearly
every comment questions Allen Holub's credibility. This is not an
authoritative source, by any means. One commenter even states:

"We have countless of examples of projects / systems that were and are
successful (the Java source code itself being one) using OO concepts
that are contrary to what Holub advocates. In other words, most of us
has been successful doing what he says we shouldn't do and what he
claims won't work well."
That just goes to prove that for every opinion there is a different opinion.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Dec 5 '06 #75
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:hu******** *************** *******@comcast .com...
>>Tony Marston wrote:
>>>Why is it so difficult for you to accept that YOUR opinion is not the
ONLY opinion that is allowed to exist? Just because you can quote some
people who agree with you does not make you right. I have quoted from
other sources who agree with me, yet you dismiss all these different
opinions as being "irrelevant ".

Your use of personal insults also shows what a juvenile mind you have.

Why is it so difficult for you to understand that you, with no real OO
experience,


Rubbish. I have been writing OO software that works for 4 years.
No, you haven't, Tony. You've been writing crap for four years and
calling it OO software.
>
>>and in direct conflict with industry-recognized experts such as Booch,
Jacobson and Rumbaugh, as well as virtually every college level course on
the country, are full of shit?


There is no such thing as one set of experts with whom EVERYBODY agrees.
There are lots of people with lots of conflicting opinions. I happen to
disagee with your opinions, and I have quoted other people who also
disagree.
Every industry-recognized expert, virtually every college professor and
most experienced designers around the world disagree with you.

But you're too stoopid to see that.
>
>>Because you're stoopid, that's why.

And the insults are because you are too stoopid to understand anything
else, Tony.

People around here are laughing at you. Your stoopidity is beyond
comprehensi on by anyone with any intellect.


Your juvenile insults show just how small minded you really are.
And you're inability to understand just how stoopid you are and what an
arsehole you're making of yourself in this group shows how closed-minded
you are and has everyone laughing at you.

You're just another stoopid troll with delusions of competency, Tony.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Dec 5 '06 #76
Tony Marston wrote:
This is a PHP newsgroup, not an OO newsgroup, so the discussion of
interfaces concerns PHP, and in PHP interfaces are optional and unnecessary.
Again, you don't understand the original contest - which was interfaces
as defined in OO terms. And since PHP is an OO language, it is
perfectly appropriate in this newsgroup.

But since you don't know shit about it, but are determined to stuff your
comments in here anyway, just like any troll, you try to change the subject.

YOU are the only one who has brought up PHP interfaces, Tony. And no
one else is discussing them.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Dec 5 '06 #77
Tony Marston wrote:
"Michael Fesser" <ne*****@gmx.de wrote in message
news:4u******** *************** *********@4ax.c om...
>>.oO(Jerry Stuckle)

>>>You notice how Tony refuses to answer your question?

Yep.

>>>I'm wondering - does the term megalomaniac ring a bell? Or do you think
it's just that he's beyond stoopid?

I don't know, but actually I don't really care at all. He has just
proven that any attempt to further discuss these things doesn't make
sense. He is always right, the rest of the world is wrong.


I am not wrong. I have made two simple statements that you cannot disprove:

(a) In PHP interfaces are not necessary.
(b) Enapsulation does not mean that all variables must be declared private
or protected.

What's so difficult to understand about that?
You're wrong because:

(a) Interfaces, as defined in OO terms (which is what we were
discussing, and PHP is an OO language) are necessary. They are how you
interact with the object, and
(b) Proper encapsulation means that all variables are defined as
private, because the way the data is stored (variable name, data type,
etc.) is a part of the implementation.

And on this every industry-recognized expert agree. It's even how they
teach it in all of the College courses. But of course, they are all
wrong, and only Troll Tony is right.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Dec 5 '06 #78

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:he******** *************** *******@comcast .com...
Tony Marston wrote:
>"Michael Fesser" <ne*****@gmx.de wrote in message
news:4u******* *************** **********@4ax. com...
>>>.oO(Jerry Stuckle)
You notice how Tony refuses to answer your question?

Yep.
I'm wondering - does the term megalomaniac ring a bell? Or do you think
it's just that he's beyond stoopid?

I don't know, but actually I don't really care at all. He has just
proven that any attempt to further discuss these things doesn't make
sense. He is always right, the rest of the world is wrong.


I am not wrong. I have made two simple statements that you cannot
disprove:

(a) In PHP interfaces are not necessary.
(b) Enapsulation does not mean that all variables must be declared
private or protected.

What's so difficult to understand about that?

You're wrong because:

(a) Interfaces, as defined in OO terms (which is what we were discussing,
and PHP is an OO language) are necessary.
In PHP interfaces are NOT necessary.
They are how you interact with the object, and
Wrong. You interact with an object by calling an object's method. The fact
that a method may have an optional interface declaration has nothing to do
with it.
(b) Proper encapsulation means that all variables are defined as private,
Wrong. Encapsulation simply means putting all the data for an object, and
the operations which act upon that data, into a single class. There is no
requirement to make all the data private, as there is no requirement to make
any methods private.
because the way the data is stored (variable name, data type, etc.) is a
part of the implementation.

And on this every industry-recognized expert agree.
Not everybody agrees with your description, industry expert or not. I
certainly don't
It's even how they teach it in all of the College courses. But of
course, they are all wrong, and only Troll Tony is right.
I am right in the following:

(a) In PHP interfaces are not necessary.
(b) Encapsulation does not mean that all variables must be declared private
or protected.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Dec 6 '06 #79
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:he******** *************** *******@comcast .com...
>>Tony Marston wrote:
>>>"Michael Fesser" <ne*****@gmx.de wrote in message
news:4u***** *************** ************@4a x.com...
.oO(Jerry Stuckle)

>You notice how Tony refuses to answer your question?

Yep.

>I'm wondering - does the term megalomaniac ring a bell? Or do you think
>it's just that he's beyond stoopid?

I don't know, but actually I don't really care at all. He has just
proven that any attempt to further discuss these things doesn't make
sense. He is always right, the rest of the world is wrong.
I am not wrong. I have made two simple statements that you cannot
disprove:

(a) In PHP interfaces are not necessary.
(b) Enapsulation does not mean that all variables must be declared
private or protected.

What's so difficult to understand about that?

You're wrong because:

(a) Interfaces, as defined in OO terms (which is what we were discussing,
and PHP is an OO language) are necessary.


In PHP interfaces are NOT necessary.

>They are how you interact with the object, and


Wrong. You interact with an object by calling an object's method. The fact
that a method may have an optional interface declaration has nothing to do
with it.
And in OO terms that is the INTERFACE! But you don't know anything
about OO, that's obvious.
>
>(b) Proper encapsulation means that all variables are defined as private,


Wrong. Encapsulation simply means putting all the data for an object, and
the operations which act upon that data, into a single class. There is no
requirement to make all the data private, as there is no requirement to make
any methods private.
Wrong again, Troll Tony.
>
>>because the way the data is stored (variable name, data type, etc.) is a
part of the implementation.

And on this every industry-recognized expert agree.


Not everybody agrees with your description, industry expert or not. I
certainly don't
But you've already shown you don't understand OO, have no idea what good
programming practices are, and are just plain stupid. So that doesn't
surprise me.

And you know what? I really don't give a damn if you agree or not. I
get my answers from industry-recognized experts such as Booch, Iverson
and Rumbaugh, not some wanna-be's blog.

Try reading what the REAL EXPERTS have to say. Then try taking a
college level course on OOAD. They will all say the same thing. YOU'RE
WRONG!
>
>It's even how they teach it in all of the College courses. But of
course, they are all wrong, and only Troll Tony is right.


I am right in the following:

(a) In PHP interfaces are not necessary.
(b) Encapsulation does not mean that all variables must be declared private
or protected.
And your head is still up your ass. Stupid troll.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Dec 6 '06 #80

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1813
by: verbatime | last post by:
Please explain me how this works - or should work: Got my two classes - bcBasic (baseclass) and the derived cBasic. //--------------------------------------- class bcBasic { int number; virtual long myfunc(void); }
45
3638
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes themselves are an exception to this), and 'bootstrap' your program by instantiating a single application object in main(), would that place any limitations on what you could accomplish with your program? Are there any benefits to doing things that...
3
2068
by: Bryan Parkoff | last post by:
I have C++ Primer Third Edition -- Author Stanley B. Lippman and Josee Lajoie. I have been studying it for couple months however it does not provide a valuable information which it is about "friend to class". I am very disappointed because it is the way how C++ Compiler is designed. I assume that "friend to class" is not the good option. If CMain class is initialized before CA class, CB class, and CC class are initialized inside CMain...
14
3811
by: Pratts | last post by:
I am a new one who have joined u plz try to help me bcoz i could not find ny sutiable answer foer this Question Qus>>why do we need classes when structures provide similar functionality??
6
3370
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to create instance of abstract class ColorSpace". I never try to create a class ColorSpace and don't really want to create a regular class with virtual methods. Does anyone know why I am having this problem? The code seems to run fine and I can actually...
11
3855
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you experts. I would like to produce Javascript classes that can be "subclassed" with certain behaviors defined at subclass time. There are plenty of ways to do this through prototyping and other techniques, but these behaviors need to be static and...
5
2011
by: Chris Szabo | last post by:
Good afternoon everyone. I'm running into a problem deserializing a stream using the XmlSerializer. A stored procedure returns the following from SQL Server: <Student StudentId="1" Status="1" Gpa="3.50"> <Person Id="1" FirstName="FirstName0" LastName="LastName0" MiddleInitial="W"/> </Student> In my code, person is the base class and student extends it. When I
2
2376
by: miked | last post by:
I am architecting in a read only class for use in mapping data to a business object. The object makes strong use of nested classes and their ability to access protected fields. The downside is when a nested class inherits from it’s parent class you get this infinite class chain in intellisense when consuming the class. To get around this I created two child classes Reader and Writer which require a base Person object. When consuming...
47
4055
by: Larry Smith | last post by:
I just read a blurb in MSDN under the C++ "ref" keyword which states that: "Under the CLR object model, only public single inheritance is supported". Does this mean that no .NET class can ever support multiple inheritance. In C++ for instance I noticed that the compiler flags an error if you use the "ref" keyword on a class with multiple base classes. This supports the above quote. However, under the "CodeClass2.Bases" property (part...
0
11027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10682
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10761
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9513
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4563
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.