PHPBuilder - PEAR Primer Page 7



RSS Twitter
Articles Pear

PEAR Primer - Page 7

by: Joe Stump
|
December 26, 2002

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.
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.

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Joe Stump

Comment:



Comment:

(Maximum characters: 1200). You have characters left.