Re: Classes - Dumb question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 11 October 2007, Jay Blanchard wrote:
> [snip]
> okay, this is really (!) embarassing, but I have to ask:
>
> Why would I want to use classes in PHP?
>
> I have been using PHP for years now and writing the "normal" functions all
> the time. I have never even bothered working with classes, but now I would
> love to know what makes the classes so special...
>
> Please go easy on me ;o) Just trying to make another step :o)
> [/snip]
>
> Do not be embarrassed, this is a very good question.
>
> First of all what you call "normal" is procedural or functional
> programming. There is nothing wrong with doing things this way and may be
> especially quick and efficient when doing basic web sites and applications.
> Document well and you will have no problem maintaining your code.

One correction.  What is being described is procedural or imperative 
programming.  Functional programming is another beast entirely (closures, 
first-class functions, immutable variables, etc.).  PHP is not a functional 
language by any stretch of the imagination.  For functional programming, see 
Erlang, Haskel, ML, LISP, and to a lesser extent Javascript.  

That's not a knock against PHP, mind you; I'm just pointing out that 
functional programming is something different than what you are describing.  
It's a common point of confusion because in a procedural language 
(traditional PHP, C, etc.) you do everything with functions, so "it's 
functional".  The difference is that a function is not a base data type, 
which is a key component of a functional language.

</semantic nitpick>

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux