difference between function() and class?
Posted 15 July 2006 - 05:53 AM
Posted 15 July 2006 - 06:47 AM
Think of a class as a group of functions that are used to manipulate the same amount of data.
Say you pull a user from the database. You would have to assign many variables accross multiple pages if you had any sort of complexity to your member system.
An easier way would be..
$user = new user(2)[/php) (assuming user is the class, and 2 is the userid it pulls from the databse, your contructor function would populate all of the users information, which is easily grouped together and used like... [code=php:0]print "Hello ". $user->firstName . " welcome to thiswebsite. Your last login was " . $user->lastLogin
It's really a small and silly example, but if you let yourself think a little at the possibilities (and this isnt the only one, polymorphism is another GREAT feature of classes)
I hope this helped shed some light..
Come visit my site to see my latest projects
Posted 15 July 2006 - 07:30 AM
Posted 15 July 2006 - 08:34 AM
An advance programmer use CLASS. //Object Oriented programming
A class may compose of variables, functions and etc.
Class make you programming logic very organize.
If you want full bloom OOP languages you use C++ or Java.
Please take note OOP in PHP is not full bloom yet.
But don't worry they are ways to make it full bloom,
just go ahead and study CLASS and OOP topics.
I'm sure you will find the hiden treasure.
enjoy the info!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users