To wrap things up I’ll finish with a simple example of using the User class from within your site.
<?php
require_once('User.php');
$user =& new User($_COOKIE['userID']);
if(!Base::isError($user) && $user->isAdmin())
{
echo "You are an admin!";
}
else
{
echo "Go AWAY!";
}
?>
One thing I started to notice the more I used PEAR was that I ended up having a lot less code in my final
application. This is a great thing about OOP. Once you get your base class working correctly you know it’s
always going to work and errors you encounter will most likely be in your very small final application. To
boot your code is abstracted and more portable.
application. This is a great thing about OOP. Once you get your base class working correctly you know it’s
always going to work and errors you encounter will most likely be in your very small final application. To
boot your code is abstracted and more portable.
Related Materials
About the Author
Joe Stump is in his last semester at Eastern Michigan University studying Computer Information Systems. He enjoys
creating complex web applications using PHP, MySQL, and XML. You can find him at http://www.joestump.net or email him at joe (at) joestump (dot) net.
creating complex web applications using PHP, MySQL, and XML. You can find him at http://www.joestump.net or email him at joe (at) joestump (dot) net.