PEAR Articles
  Home arrow PEAR Articles arrow Page 3 - My PEAR: The Beginning
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PEAR ARTICLES

My PEAR: The Beginning
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-17

    Table of Contents:
  • My PEAR: The Beginning
  • Installing PEAR
  • PEAR Coding Standards
  • Functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    My PEAR: The Beginning - PEAR Coding Standards


    (Page 3 of 4 )

    While there is no commonly agreed way of writing code, the creators of PEAR have created their own way of writing code known as PCS or PEAR Coding Standards. In general you don't have to follow these standards, but if you ever want to submit your work to PEAR,  you will have to follow them. If you visit the PEAR website you will find a lot of information about PEAR Coding Standards so I will not be going into great detail here.

    To start with, all code should be indented correctly according to its context by using a suitable number of spaces. PEAR dictates four spaces. Also, if a parenthesis is optional but its inclusion improves clarity, then its inclusion is required. Comments are encouraged wherever possible. Avoid using # when commenting; instead, use the "//" for single line comments or the "/*" and "*/" for multi-line comments.

    PEAR also dictates that all starting and finishing blocks of code are done like so: starting "<?php" and finishing "?>". This is mostly because some servers may throw an error if you use "<?" for the starting block. This requirement ensures that your code is more platform independent.

    As for control structures, the curly braces should always be used. Control structures may include:

    • for
    • foreach
    • while
    • if

    PEAR dictates that curly braces should be used even if there is only a single line in the block. The PHP interpreter is very lax in this regard. This is mainly for improving clarity.

    Here is an example of PEAR compliant commenting:

    <?php

    //now check if the values in the two variables match

    if ($a==$b) {

    echo "the values match";

    }else{

    echo "The values do not match.";

    }

    /*In this block of code we evaluated the two variables to see if they matched.

    Appropriate messages where printed out to show the outcome

    */


    ?>

    The above example shows how to make single and multi-line comments that are PEAR compliant.

    More PEAR Articles Articles
    More By David Web


     

    PEAR ARTICLES ARTICLES

    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT