How do libraries work?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

How do libraries work?

Post by impulse() »

This question has arose from reading about Swiftmailer. I realise that by using Swiftmailer you don't have to use PHPs mail function. By using Swiftmailer are you creating a new function within PHP so I could now do

Code: Select all

swiftmailer($message, $subject, $to, $from)
That's pseudo by the way.

instead of

Code: Select all

mail($message, $subject, $to, $from)
?

Regards,
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The way libraries work depends entirely on their code. Swift is a class library (for the most part), so most interactions will be with objects. While a library could create functions, many do, they don't necessarily have to do so.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

generally if you want to know how a library works, look at it's documentation.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I didn't want to look at Swiftmailers inner-workings or any other libraries inner-workings. I was more curious of what a library in PHP actually was and why you needed them. It's become clear now though.
From what I understand you can import classes from libraries and create functions with libraries. If that isn't right it better be close :)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Please visit the link I posted. Usually libraries will have documentation... and the documentation will tell you EXACTLY how to use the library. Libraries are just packaged functionality. Swiftmailer allows you to send emails with attachments, smtp authentication, and much more... all of which , d11wqt has generously documented for you at the link I posted. It does not tell you the "inner-workings". It tells you how to use the library.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

To define what a library is if that's what you mean, I'll take a stab at it:

A group of files containing objects and/or functions to provide an interface to extended functionality in a programming language. Libraries usually consist of several components which, when working together can make development of specific functionality in application more efficient.

For example (since you've chosen to mention swift) Swift Mailer consists of various categories of objects:

* The Core class
* Connection interfaces
* Authentication Mechanisms
* Plugins

Put them toegther and that's the library.
Post Reply