Can someone please explain to me when is a class useful over a set of
functions?
Almost always. Object oriented programming offers many many advantages
(that I cannot get into depth on here). There are a few exceptions
where you would not use classes, such as utility functions like max()
and
Here is an excellent article describing
classes/objects - what they are and are not.
http://phpmag.net/itr/online_artikel/psecom,id,284,nodeid,114.html
olinux
Can someone please explain to me when is a class
useful over a set of
functions?
__
Do you
Thank you for your 2 cents I am just learning and appreciate your comments.
- Original Message -
From: Michael Hall [EMAIL PROTECTED]
To: Chris Crane [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, July 16, 2002 11:13 PM
Subject: Re: [PHP] Classes vs. Functions
[snip]
Could someone please explain the difference between classes and functions
and how to use a class. I write alot of PHP, but I never understood this at
all. I use an include statement in many of my pages and include a file with
a bunch of functions. For instance, I might have a function
To add to the below, object classes, can have their own set of functions, called
methods. These methods are specific to the function, and ALL functions within a class
treat any properties (variables) within the class as global.
So if you have a class Car with two properties (Make and Model),
It helps a little bit, thank you. Could you provide some code as to what a
Class looks like. I am just trying to understand it better and if I see it,
it might help.
Jay Blanchard [EMAIL PROTECTED] wrote in message
[snip]
example?
[/snip]
http://www.devshed.com/Server_Side/PHP/FormValidatorClass/page1.html
Good tutorial
Jay
*
* Want to meet other PHP developers *
* in your area? Check out: *
* http://php.meetup.com/*
* No developer is an island
Here is a sample code (don't take this as gospel... Jay knows more about OOP than I
do, I'm sure!):
class Car {
var $make;
var $model;
function setMake($x) {
$this-make = $x;
}
function setModel($y) {
$this-model = $y;
}
}
$make and $model are the
This helps quite a bit Thank you.
I am just wondering if I should make classes instead of functions? What
would be the benefit of that? Do you know?
Martin Clifford [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Here is a sample code (don't take this as gospel...
info, makes it easier to keep track of.
Hope this helps,
Steve.
-Original Message-
From: Chris Crane [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 16, 2002 11:07 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Classes vs. Functions
It helps a little bit, thank you. Could you provide some code
[snip]
This helps quite a bit Thank you.
I am just wondering if I should make classes instead of functions? What
would be the benefit of that? Do you know?
[/snip]
You should keep classes and functions seperate in your thought process, they
are not the same and not meant to do or be the same
I'm still trying to figure that out, but the fog is clearing slowly but steadily :o)
From what I've heard on this and other lists, it's all a matter of preference.
Obviously those that come from an object-oriented environment (Java, etc), will lean
toward this method, while others stay with
thanks Jay.
Jay Blanchard [EMAIL PROTECTED] wrote in message
000e01c22cdd$0d0c7530$8102a8c0@niigziuo4ohhdt">news:000e01c22cdd$0d0c7530$8102a8c0@niigziuo4ohhdt...
[snip]
This helps quite a bit Thank you.
I am just wondering if I should make classes instead of functions? What
would be the
Is there an advantage to Classes vs. Functions?
Jay Blanchard [EMAIL PROTECTED] wrote in message
000c01c22cdb$11485c10$8102a8c0@niigziuo4ohhdt">news:000c01c22cdb$11485c10$8102a8c0@niigziuo4ohhdt...
[snip]
example?
[/snip]
http://www.devshed.com/Server_Side/PHP/FormValidatorClass/page1.html
: [EMAIL PROTECTED]
Subject: Re: [PHP] Classes vs. Functions
It helps a little bit, thank you. Could you provide some code as to what a
Class looks like. I am just trying to understand it better and if I see
it,
it might help.
Jay Blanchard [EMAIL PROTECTED] wrote in message
000401c22cd8$
: Chris Crane [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 16, 2002 11:40 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Classes vs. Functions
Wow...this is pretty cool.
Do you HAVE to declareall your varibles ahead of time?
Steve Bradwell [EMAIL PROTECTED] wrote in message
ðÒÉ×ÅÔ!
Martin Clifford wrote:
Could someone please explain the difference between classes and functions
and how to use a class.
Well, that's a 1 billion $$ question. I don't think one can fully grasp
that difference by reading an email. I strongly suggest you to buy
yourself a book about
Martin Clifford wrote:
Could someone please explain the difference between classes and
functions
and how to use a class.
Whether you should like OOP or not is a religious matter, so I will not
enter the field. OOP has its pluses and its minuses. It's a technique,
not an ultimate
On 17 Jul 2002 at 12:43, Michael Hall wrote:
There is no simple answer here. I have started using classes where I
find I am writing a lot of related functions that share similar
parameters. Database connection and queries are a good example.
Authentication is another.
Yeah.
I have
[snip]
A CLASS after all is just a collection of functions with a
data model. But ... there is modular and then there is OO imho.
[snip]
A class is more than just a bunch of functions that have been placed
together. If you want to do that, then you might as well just throw them all
into the
20 matches
Mail list logo