View Single Post
Old 06-19-2009, 03:06 PM   #3 (permalink)
adamdecaf
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Null, I've always learned the language and then applied it. Plus for competitions I can't use any frameworks so starting from scratch is really helpful.

Quote:
Originally Posted by knight13 View Post
I have always seen people talking about frameworks, but i never seen it mentioned in any of the php books i read or at least i do not think i have, what exactly are they? and what are they used for?
PHP frameworks are just like JS frameworks in they provide a simple solution to problems. They are often premade software (wordpress, joomla, jquery, mootools, ect...).

A few days ago there was a PHP Mail framework, it really simplified the process of sending mail.

For example this is what you would normally code:
PHP Code:
<?php
// Declare the variables
$to $_POST['to'];
$from "From: adam@example.com";
$subject $_POST['subject'];
$message $_POST['message'];

// Now validate the three $_POST's.
/**
 *
 *  ...........................
 *
 */

// Now send the message.
flush();
   
mail($to$subject$message$frrom);
flush();

echo 
'Message Sent!';

?>
While the PHP framework may have just required this.
PHP Code:
<?php
// Collect the information
$mail = new MAIL;
$mail->to($_POST['to']);
$mail->subject($_POST['subject']);
$mail->message($_POST['message']);
$mail->from("adam@example.com");

$mail->send();
?>
The framework will deal with any and all errors, validation, and editing.

Frameworks just make the job(s)/task(s) simpler, at the cost of reliance on licenses and learning the "language".
__________________
My Site
adamdecaf is offline  
Reply With Quote