How do libraries work? [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lafflin
Forum Contributor
Posts: 123
Joined: Thu Jul 26, 2007 6:26 pm

How do libraries work? [solved]

Post by lafflin »

Hello, I'm not sure this question is in the right place, but I just have a simple question. How do libraries work? Is a library placed in an external file that you can place into your directory and call functions from? I'm a newb and I'm trying to take it to the next level, but it seems like all the library sites assume that I know how to implement them, but I don't.


Thanks for any guidance given.
Last edited by lafflin on Wed Sep 26, 2007 4:11 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Libraries are generally a grouping of independent code. They may be one or more functions and/or classes. They are not applications in themselves and are typically not an platform to build an entire application on -- those are called frameworks. Instead they focus on a specific task. Examples of libraries range from the MySQL functions found in PHP to Swift Mailer to my SHA256 implementation.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

To continue on feyd's explanation, libraries generally allow you do do complicated tasks, but give you an interface that is more easy to work with. For example, mailing 1000 customized emails with attachments and only one To: parameter might be pretty tedious task if you were to do it without a library. With swiftmailer, it's relatively simple.

To use libraries, you simply include (or require) the files you want to use, and follow the documentation outlined on the library's site. If the library has bad docs, don't use it. No library should assume you know how to use it. One of the deciding factors when I'm choosing a library is good documentation.
lafflin
Forum Contributor
Posts: 123
Joined: Thu Jul 26, 2007 6:26 pm

Post by lafflin »

Hey guys, thanks alot. That was exactly what I needed to know. I feel like a a big door was just unlocked that leads to a warp zone.
Post Reply