473,890 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object Oriented PHP

I am new to PHP, just one day new. But I am otherwise a seasoned
programmer on many other languages like C, VB 6, C#, VB.NET, Win32
platform and have some tiny bit experience in MFC, C++, Python.

All the tutorials I read so far about PHP contain procedural examples.
I haven't yet come accross a tutorial on the object oriented PHP. Could
someone point me to one?

Jun 17 '06
73 4556
Tony Marston wrote:
"NC" <nc@iname.com > wrote in message
news:11******** **************@ b68g2000cwa.goo glegroups.com.. .
427SOHC wrote:
If I haven't worked with OOP much would PHP be a safe
starting point, or is there a better programming language
to start with?


If you haven't worked with OOP before, start by learning OOP in the
language you otherwise know well. Once you understand the basic
concepts (encapsulation, inheritance, polymorphism, etc.), you will be
able to ask intelligent questions about how those concepts are
implemented in other languages.

Also, note that PHP 4 and PHP 5 have different object models; the one
in PHP 5 is more in line with what you find in other languages, while
the one in PHP 4 is simpler, but more restrictive.

"More restrictive" is a point of view. It is possible to write OO code in
PHP 4 that also runs in PHP 5, as I have proved with my sample application
and later my full-blown framework.

AFAIAC the extra OO features in PHP 5 are nothing more than eye candy as
they do not provide any additional functionality which is worthy of merit.
They were only included to appease the OO purists.


Actually, things like private declarations are very important. They are
unimportant only to those who don't understand OO programming - or those who are
sloppy in their implementations .

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

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:25******** *************** *******@comcast .com...
Tony Marston wrote:
"NC" <nc@iname.com > wrote in message
news:11******** **************@ b68g2000cwa.goo glegroups.com.. .
427SOHC wrote:

If I haven't worked with OOP much would PHP be a safe
starting point, or is there a better programming language
to start with?

If you haven't worked with OOP before, start by learning OOP in the
language you otherwise know well. Once you understand the basic
concepts (encapsulation, inheritance, polymorphism, etc.), you will be
able to ask intelligent questions about how those concepts are
implemente d in other languages.

Also, note that PHP 4 and PHP 5 have different object models; the one
in PHP 5 is more in line with what you find in other languages, while
the one in PHP 4 is simpler, but more restrictive.

"More restrictive" is a point of view. It is possible to write OO code in
PHP 4 that also runs in PHP 5, as I have proved with my sample
application and later my full-blown framework.

AFAIAC the extra OO features in PHP 5 are nothing more than eye candy as
they do not provide any additional functionality which is worthy of
merit. They were only included to appease the OO purists.


Actually, things like private declarations are very important. They are
unimportant only to those who don't understand OO programming - or those
who are sloppy in their implementations .


You don't *need* private declarations. Code will work just as well without
them.

--
Tony Marston

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

Jun 24 '06 #12
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
Actually, things like private declarations are very important. They are
unimportant only to those who don't understand OO programming - or those
who are sloppy in their implementations .


You don't *need* private declarations. Code will work just as well without
them.


What the heck! Let's just throw away multiply and divide. We don't
*need* them. We can just use add and subtract.

Heck! Why do we need subtract? We can just add negative values.

Hey! Assembler works well without private declarations. Let's just pitch
PHP all together.

The point is that constructs are added to language to assist in the
functionality and maintainability of programs written in that language.
The introduction of private and protected adds to the maintainability
both through its inherent protection capabilities and its clarity of
intent for the maintainer.

Now if PHP could just get polymorphism...

-david-

Jun 25 '06 #13
David Haynes wrote:
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
Actually, things like private declarations are very important. They
are unimportant only to those who don't understand OO programming -
or those who are sloppy in their implementations .


You don't *need* private declarations. Code will work just as well
without them.


What the heck! Let's just throw away multiply and divide. We don't
*need* them. We can just use add and subtract.

Heck! Why do we need subtract? We can just add negative values.

Hey! Assembler works well without private declarations. Let's just pitch
PHP all together.

The point is that constructs are added to language to assist in the
functionality and maintainability of programs written in that language.
The introduction of private and protected adds to the maintainability
both through its inherent protection capabilities and its clarity of
intent for the maintainer.

Now if PHP could just get polymorphism...

-david-


Sorry I am new to PHP but use Java. My question is how can you have a
OOP Language and not have polymorphic features. Sorry, I have not gotten
up to par on PHP yet.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Jun 25 '06 #14
IchBin wrote:
David Haynes wrote:
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

Actually, things like private declarations are very important. They
are unimportant only to those who don't understand OO programming -
or those who are sloppy in their implementations .
You don't *need* private declarations. Code will work just as well
without them.


What the heck! Let's just throw away multiply and divide. We don't
*need* them. We can just use add and subtract.

Heck! Why do we need subtract? We can just add negative values.

Hey! Assembler works well without private declarations. Let's just
pitch PHP all together.

The point is that constructs are added to language to assist in the
functionality and maintainability of programs written in that
language. The introduction of private and protected adds to the
maintainability both through its inherent protection capabilities and
its clarity of intent for the maintainer.

Now if PHP could just get polymorphism...

-david-


Sorry I am new to PHP but use Java. My question is how can you have a
OOP Language and not have polymorphic features. Sorry, I have not gotten
up to par on PHP yet.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)


PHP does have some polymorphic-like abilities, but that's because of the untyped
nature of the variables.

PHP is getting better in it's OO aspects, but I doubt it will ever be quite like
Java. There's just a basic difference between languages with typed and untyped
variables.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 25 '06 #15
Jerry Stuckle wrote:
IchBin wrote:
David Haynes wrote:
Tony Marston wrote:

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

> Actually, things like private declarations are very important.
> They are unimportant only to those who don't understand OO
> programming - or those who are sloppy in their implementations .
You don't *need* private declarations. Code will work just as well
without them.
What the heck! Let's just throw away multiply and divide. We don't
*need* them. We can just use add and subtract.

Heck! Why do we need subtract? We can just add negative values.

Hey! Assembler works well without private declarations. Let's just
pitch PHP all together.

The point is that constructs are added to language to assist in the
functionality and maintainability of programs written in that
language. The introduction of private and protected adds to the
maintainability both through its inherent protection capabilities and
its clarity of intent for the maintainer.

Now if PHP could just get polymorphism...

-david-


Sorry I am new to PHP but use Java. My question is how can you have a
OOP Language and not have polymorphic features. Sorry, I have not
gotten up to par on PHP yet.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
_______________ _______________ _______________ _______________ ______________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)


PHP does have some polymorphic-like abilities, but that's because of the
untyped nature of the variables.

PHP is getting better in it's OO aspects, but I doubt it will ever be
quite like Java. There's just a basic difference between languages with
typed and untyped variables.

Thanks for the info..

I read something about PHP version 5, OOP\OOD and typed Objects. So I
guess there are really not fully typed object. I have to read more and
not take OOP references as used by say smalltalk and Java and others.

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Jun 25 '06 #16
Jerry Stuckle wrote:
PHP does have some polymorphic-like abilities, but that's because of the
untyped nature of the variables.

PHP is getting better in it's OO aspects, but I doubt it will ever be
quite like Java. There's just a basic difference between languages with
typed and untyped variables.


I was thinking about this the other day and it may not be all that
difficult to add it.

Consider that you can already type the arguments to the constructor.
Given this, it would not be all that hard to derive a typed signature
which could then be applied.

-david-

Jun 25 '06 #17
David Haynes wrote:
Jerry Stuckle wrote:
PHP does have some polymorphic-like abilities, but that's because of
the untyped nature of the variables.

PHP is getting better in it's OO aspects, but I doubt it will ever be
quite like Java. There's just a basic difference between languages
with typed and untyped variables.

I was thinking about this the other day and it may not be all that
difficult to add it.

Consider that you can already type the arguments to the constructor.
Given this, it would not be all that hard to derive a typed signature
which could then be applied.

-david-


I really don't know how hard it would be to add - but I would like to see it
added. One thing I don't like all that much is the untyped variables. It makes
things "easy" - but leads to some sloppy programming.

It also means you can't overload functions - at least not with the same number
of parms. Typing the constructor arguments is a good start. But expanding that
to other functions without breaking existing code might be more difficult.

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

"David Haynes" <da***********@ sympatico.ca> wrote in message
news:Tv******** ***********@fe2 6.usenetserver. com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
Actually, things like private declarations are very important. They are
unimportant only to those who don't understand OO programming - or those
who are sloppy in their implementations .


You don't *need* private declarations. Code will work just as well
without them.


What the heck! Let's just throw away multiply and divide. We don't *need*
them. We can just use add and subtract.

Heck! Why do we need subtract? We can just add negative values.

Hey! Assembler works well without private declarations. Let's just pitch
PHP all together.

The point is that constructs are added to language to assist in the
functionality and maintainability of programs written in that language.
The introduction of private and protected adds to the maintainability both
through its inherent protection capabilities and its clarity of intent for
the maintainer.

Now if PHP could just get polymorphism...


OOP with PHP already has polymorphism. You obviously don't know what
polymorphism means.

--
Tony Marston

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

Jun 25 '06 #19

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:4K******** *************** *******@comcast .com...
David Haynes wrote:
Jerry Stuckle wrote:
< snip >
I really don't know how hard it would be to add - but I would like to see
it added. One thing I don't like all that much is the untyped variables.
It makes things "easy" - but leads to some sloppy programming.

It also means you can't overload functions - at least not with the same
number of parms. Typing the constructor arguments is a good start. But
expanding that to other functions without breaking existing code might be
more difficult.


You don't need function overloading in PHP. Why? First you need to look at
why other languages need it:
(a) To accept arguments of different types.
(b) To make some arguments optional.

With PHP you can accept an argument of any type and then cast it to the one
you want, so item (a) is irrelevant.

With PHP you can define a default value for an argument if it is not
supplied, so item (b) is irrelevant.

--
Tony Marston

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

Jun 25 '06 #20

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

Similar topics

0
1670
by: Benjamin C. Pierce | last post by:
The Twelth International Workshop on Foundations of Object-Oriented Languges (FOOL 12) Saturday 15 January 2005 Long Beach, California, USA Following POPL 05 The search for sound principles for object-oriented languages has given rise to much work on the theory of programming languages during the past two decades, leading to a better understanding of the key
5
2932
by: Martin | last post by:
When was inheritance intruduced into object oriented programming? More generally, does anyone know or have any sources on when the different features were introduced into object oriented programming?
34
7135
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
65
4309
by: Roger Smythe | last post by:
A means for the progressive decomposition a problem space into increasingly simpler component parts such that these component parts represent higher levels of conceptual abstraction, and are completely independent of each other except for their well-defined interfaces. This was an attempt to explain the gist of OOP to programmers accustomed to the structured programming paradigm. I tried to explain OOP in terms of ideals that can be...
14
2945
by: Rookie | last post by:
Is C an object oriented programming language?
100
5337
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
8
1808
by: cppig1995 | last post by:
C++ is not only object-oriented language. I think the description of this group have to be changed. :-) Have fun! ---- cppig1995 (cppig1995@gmail.com) Daejeon Metropolitan City, Republic of Korea 11 years old in Western age.
47
5979
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web site at http://ldeniau.web.cern.ch/ldeniau/html/oopc/oopc.html. The approach is very instructive. I know that I could do much of this stuff with e.g. C++, but the intellectual challenge of implementing these concepts with pure ANSI C is relevant to...
46
3050
by: ajba74 | last post by:
Hi fellows, I am reading some books to learn the C programming language, and sometimes I have the feeling that when somebody becomes a C expert, he must learn a more modern and object-oriented language. When I read things like "... C++ is an evolution of C ..." or "... C is a subset of C++ ..." I tend to believe that I will have to learn C+ + sooner or later. It sounds like C++ is the future and C is the past (and will be no longer...
3
1551
by: notnorwegian | last post by:
i have some confusion over this. sure a class is basically a classification, like for example an animal or flower. and an object/instance of that class is then for example a cat. an object is an instance of a class. that i know, i also know how to program with classes etc. i am just confused about the term object-oriented.
0
9970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10794
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
10896
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
10443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8000
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
5830
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4652
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
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.