The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

A class can be a collection of functions, therefore, you are still passing to a function whether it is in a class or not. Speaking of databases, what if you ever had to switch from Access to MS SQL? If the database items had been implemented in a class, you could easily change between database types. Not only that, but if you were a software company you could provide your software to many different database platforms with very little coding.

While providing new functionality, OOP also enhances readability. Compare a 10,000 line OOP program vs a 10,000 line functional one and you'll see a huge difference. If you ever have to read someone else's spaghetti code, you'll understand.

As far as examples to an online database, google has a pretty large one hehe. Look at Google Suggest which uses ajax and provides suggestions as you start typing in the search field:http://www.google.com/webhp?complete=1&hl=en

Also, have you ever sold an item to ebay? They use ajax when selecting categories of an item you are trying to sell. You select from a high level category (sports), then a new dropdown is prefilled based on what you chose(football, basketball...), and then based on that dropdown, yet another dropdown is prefilled (high school, college, professional) based on what you chose there and so on.

For code examples, just google "ajax suggest" and you'll get a lot of hits.

An object encapsulates the methods (functions) and data within itself. Maybe this simple program (tested with PHP 4.4.1) with comments may answer the question of how classes pass data back and forth between methods (functions in procedural languages). Stepping through the code, comments and running it should clarify a few things up. Again, this is very simple, the real power, lays in creating abastract classes and polymorphism.

// Uh oh, the vet puts Bopper on a diet!
// now displays "Bopper is a dog and eats Diet Doggie Crunch";

$dog->set_food_type("Diet Doggie Crunch");
$dog->show_the_pet();

// Uh, Oh, the pet shop owner wants to add fish with a PH data field.
// Well, makes no sense to add it to pets, since a dog or cat doesn't need PH
// so, we will create a new class called fish, which inherits all the data
// fields and methods (functions) from pet, then add the PH field to the
// fish class.

// displays "Bubbles eats Sparkle Flakes" and also displays "Bubbles has a PH Balance of 1.4

re:oop

Don't even go there with pets. I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web). And I have programmed an access frontend to sql server and mysql. I am still learning php, and only been involved in web databases (learning) for a few months. In past it was all networked applications. So after 100,000 post, someone above answered the question: Functions are used in oop.

Read this post carefully: http://www.sitepoint.com/forums/showthread.php?t=426306 , it exlpains what I'm trying to accomplish in a web database. If oop is so good how come no one can answer the really hard questions? That google thing still don't come close to what I'm trying to do. Simply have a text box to enter a search string, i.e., wh. Hit a enter or go button and have the dropdown filled with all occurrences of wh -- white freight, whitman trucking, etc. But at the same time after selecting whitman trucking, have their phone and fax filled. And if that's not enough, have other fields -- load number, etc on this same page. Then a final submit button to send this info to database. There are shipper and receiver filds also. Now I bet the google thing don't do anything this advanced. But I am going to check anyway.

Don't even go there with pets. I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web). And I have programmed an access frontend to sql server and mysql. I am still learning php, and only been involved in web databases (learning) for a few months. In past it was all networked applications. So after 100,000 post, someone above answered the question: Functions are used in oop.

Read this post carefully: http://www.sitepoint.com/forums/showthread.php?t=426306 , it exlpains what I'm trying to accomplish in a web database. If oop is so good how come no one can answer the really hard questions? That google thing still don't come close to what I'm trying to do. Simply have a text box to enter a search string, i.e., wh. Hit a enter or go button and have the dropdown filled with all occurrences of wh -- white freight, whitman trucking, etc. But at the same time after selecting whitman trucking, have their phone and fax filled. And if that's not enough, have other fields -- load number, etc on this same page. Then a final submit button to send this info to database. There are shipper and receiver filds also. Now I bet the google thing don't do anything this advanced. But I am going to check anyway.

Yeah, you are consistently mixing up two totally different discussions; OOP and AJAX. I think everyone has provided very detailed explanations about what OOP is; what exactly aren't you getting? OOP has nothing to do with your autocomplete functionality. That is AJAX, and is not that difficult.

If oop is so good how come no one can answer the really hard questions? .

Because convincing people OOP is good is painful. It's paradigm shift and your not just going to pick it up. Your going to have to invest abit of thought and time into it. Also, your arguments are both old and common and there has been discussion after discussion about this for many years. And frankly, you should be grateful people are going out of their way to help you understand.

"A nerd who gets contacts
and a trendy hair cut is still a nerd" - Stephen Colbert on Apple Users

re: Grateful

I do thank you for replying. Actually the post I referred people to is php related. I am trying to implement some ajax within php programming. If you read the post, I'm not after auto complete. I'm after something like http://www-128.ibm.com/developerwork...ro2/index.html. But instead of entering a phone number, I want to select from a dropdown.
But first narrow the dropdown results from a "enter search string box". I realize until recently this type of stuff wasn't done on the web, it's new technology. Does anyone have actual code examples I could download of this. The IBM example is close, but there is a missing link that I need to learn. I have actually worked with there example and got it working.

Don't even go there with pets. I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web). And I have programmed an access frontend to sql server and mysql. I am still learning php, and only been involved in web databases (learning) for a few months. In past it was all networked applications. So after 100,000 post, someone above answered the question: Functions are used in oop.

Well according to your other question :

Originally Posted by jim9

Still not properly answered: What's the difference of passing to a function verses passing or calling or whatever it is you do to a class library?

That is what I answered for you in the pets, "Don't even go there with pets". No, there are no functions in OOP, they are called methods and methods behave and handle data differently than "functions."

Originally Posted by jim9

I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web).

Why add insult to injury? Do you think you are the only one here that has written desktop apps? I've been custom writing desktop apps since 1986 going from C/ C++, Pascal, x86 assembly, system 36 with Cobol/RPG, PHP, Perl, and so forth, and getting paid to write them.

Don't brag on how "great" your programming skills are for desktop applications when you are clearly wanting to learn how to write server side applications.

Were here to try and help you with your questions, I think you have been provided with more than enough to answer your questions...and if not, do a search in the forums. So, why don't you review what everyone has posted, buy a book, RTFM, and get your feet wet by actually doing some server side coding.

If you have a problem with some code, that is cool, throw the question out there and I think many folks will help you out!

Sure, now-a-days you have a lot of flash and non-sence on web sites. But you know something, all the extra bull isn't really needed to simply pull records from a database, edit records, add records, etc. You take a large warehouse that ships 50 to 100 truck loads a day, if they use php as a frontend to their backend database weather oracle or mysql, or whatever, they want one thing. And that is to pull up that order, load that truck, and press on. They don't need a cute little flash movie, or something bouncing across a screen.

ok, so you quite clearly hate flashy stuff on a screen, yet you want AJAX?

as for this:

Originally Posted by jim9

Here's my point: People cannot leave well enough alone. Why can't they get something that works well and leave it alone for at least several years?

come on, thats just ridiculous.
with that attitude, 99% of the stuff we use today, that people have created and invented, would not exist.
i could go on forever:
why create the car, when we had a bike?

in this case, though;

Originally Posted by jim9

They need to search for load number 125576-5, get the info, and load the freakin truck.

im struggling to get what your 'point' is exactly; do you think the end user CGAS whether or not the language version being used to search for his 'load number 125576-5' is PHP 4 or PHP 5? i see you're saying that 'if it aint broke, dont fix it' - but PHP 5 doesnt 'break it'. the programmer breaks it with crap code - something which you've obviously encountered yourself (miaow! )

the thing is, common sense would tell you that if there is two options in anything, the one with more features, more mature, better tested, and has better testimonials (which you can take as pretty much everyone in this thread telling you PHP 5 is better) - you go with the best option available - in this case, PHP 5 applies.

as for the OOP argument that seemed to crop up out of nowhere (why, i dont know, as you seem to be looking for basic AJAX examples) - the argument is ancient. if you ask me, some people just simply dont have the capacity to pick it up. though people say its a paradigm shift; in some ways it is, in physical coding terms - but in psychological terms, no shift has taken place; it was always there, it just needed something to kick it into action, something to spark it off (displayed by the classic 'a-ha!' moment ) - the OO way of thinking is a general principle that you can apply to life, and many people do.
however, for the unfortunate few, they will never experience this, and will happily trudge through with things 'getting by, because it works' - never striving to do better, to find a better way.

My point is this, php4 is on most hosted servers in the world. There's already talk of a php6 coming out. Now to add 2 + 2 for you, before php5 is even out widespread there will be a php6. My point is exactly that, they aren't even going to let the php5 you like so much become an aldult. Use your brain, I don't mean never come up with new stuff, but good grief, let it have a life before you replace it. I would probably like php5 if it was more backwards compatable to php4. Case in point:Microsoft is real bad about that. They were coming up with new versions of access just when the current version became stabe with all the updates. But do you realize how many developers still develop in one of the older versions due to stability? Man let's progress, but let's enjoy and take a breath along the way. The way you sound, you'd build a house, live in it a week, tear it down for a bigger upgrade. Me, I'd at least live in the house for a few years first.

There were very few Backward incompatable changes relating to non-OO related programming from php4 to php5. Also have you even looked into what the changes php6 includes? The major thing is unicode support, it's not a complete rewrite as you seem to think it is.

Also, the timeframe between PHP4 and PHP5, I believe, was the largest time difference of any two previous PHP versions. PHP/FI in 1995; PHP/FI 2 in 1997; PHP 3 in 1998, PHP 4 in 2000, PHP 5 in 2004. From the start, PHP seems to have had a tendency to release a major version every 2 years or so. Further, 2 years (how long PHP5 has been out) is plenty of time for people to migrate, IMNSHO.

Thanks for wasting my time on one of the lamest articles I've ever read .

Originally Posted by jim9

Sounds like oop is nothing more than a common stored procedure, ie., IsPageLoaded type thing. Or an include used over and over again.

What text did you read that makes it "Sound like" a stored proc or include (two very different things)? Was it the "Beginners guide to Assembly" from the same author as above? OO has nothing to do with either of these. It's a layer of abstraction above (two if you count closures) that makes things easy to change and easy to work in the language of the domain.

What do you think polymorphism is?

Originally Posted by jim9

OOP is only in your mind, it doesn't exist, it's a term being thrown around.

I don't understand why you post on forums? Your attitude is pretty much going to guarantee that you drive away anybody who would be willing to help you. A shame given the quality of this forum.

You are obviously not going to make the effort to learn OO until you see a need. While you are slapping front ends on relational data, you won't. Fair enough.

You might start to see the point when you are dealing with non-tabular data, fuzzy data, or any system that has to evolve, or is poorly defined to begin with, a project with a large number of developers or one that has to be very flexible or configurable. That's normally anything that's new.

jim9 does have a good point. most hosting companies, even large companies, are still running php4. The only companies I really see running (and supporting) PHP 5 are those with pricey, dedicated servers, or $el-Cheap-O companies reselling, resold, refried, resold, then resold again beaner hosting plans at those notorious great $4.95/month rates -- with the buzz word "PHP5 installed."

I run php5 on my local machine for development, but, before launch, I fire the sites up under php4 to make sure my code still runs under php4. I do a lot of OOP programming with PHP, but, at the moment I make sure that I don't code PHP5 specific.

In regards to PHP 6, again, jim9 brought up a good argument -- php5 has not been fully adopted across the web, php 4 is still the major installed version. If it weren't, we would be knocking php5 and talking about php6 and you would have to really dig through old threads for info on php4 specifics.

jim9 does have a good point. most hosting companies, even large companies, are still running php4. The only companies I really see running (and supporting) PHP 5 are those with pricey, dedicated servers, or $el-Cheap-O companies reselling, resold, refried, resold, then resold again beaner hosting plans at those notorious great $4.95/month rates -- with the buzz word "PHP5 installed."

I hate to quote DHH but how many hosts do you need? You don't need a thousand hosts. You only need one or two. So, if there are only 10 or 20 to choose from thats not really a big deal. Also companies to follow technology generally better companies and in the end hosting is dirt cheap.

"A nerd who gets contacts
and a trendy hair cut is still a nerd" - Stephen Colbert on Apple Users

jim9 does have a good point. most hosting companies, even large companies, are still running php4. The only companies I really see running (and supporting) PHP 5 are those with pricey, dedicated servers, or $el-Cheap-O companies reselling, resold, refried, resold, then resold again beaner hosting plans at those notorious great $4.95/month rates

Where are you pulling this information from? It is simply not true anymore. Many hosts now offer either dual PHP 4/PHP 5 setups or give customers the option of PHP 4 or PHP 5.

All it takes is a few moments and your favorite search engine to realize that PHP 5 hosts are no longer a rarity. And every day more and more hosts are upgrading to PHP 5.

It is true that there are more PHP 4 hosts than PHP 5 hosts, but it is just simply not true that PHP 5 hosts don't exist or are hard to find. Just not true.

I hate to quote DHH but how many hosts do you need? You don't need a thousand hosts. You only need one or two. So, if there are only 10 or 20 to choose from thats not really a big deal. Also companies to follow technology generally better companies and in the end hosting is dirt cheap.

I only need one. It took several years of dealing with "big-name" hosting companies, (10 years to be exact), going from what the hosting reviews said was the best, etc, etc, to finally get to a company that I've actually been with for about 3 years. Before that, I've dealt with a lot of companies that start off with great support -- but, when things "break" -- crap support, no support answer, tech support with no phone number, and the infamous "fill out a ticket."

It is good to see competition blooming, the industry is now reaching a point where they are learning how to keep customers; they have to answer the phone 24/7, without a 45 minute que, without having to go through level 1, 2, 3 support talking to someone in India with a thick accent -- then finally transferring your call back to the US to talk to "top level" support -- where finally you can describe the problem and its fixed in about two minutes.

So, I agree -- somewhat, I don't think its the companies that follow technology, because as you can see, beyond the long distance call, the 3 step ticket system, talking to Ali-Babbi in India, then having your phone call finally transferred back to the US when you can ask the question and get the answer in 2 minutes or less -- great technology <not> --

but it is just simply not true that PHP 5 hosts don't exist or are hard to find. Just not true.

Of course there are PHP 5 hosts out there, and yeah, if you do a search, in the search engine of your choice, as you suggest, you will find a lot.

Just saying its hard enough to find a good host period -- and to find a good host that fully supports PHP5 is even harder.

WHen I state "good" host, it means that I've got 80+ clients that rely on my company to keep their small business to fortune 1000 company online. Clients that rely on my judgment to determine the hosting company that is reliable.