PHP
  Home arrow PHP arrow Page 4 - An Introduction to PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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? 
PHP

An Introduction to PHP
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 39
    2004-08-30


    Table of Contents:
  • An Introduction to PHP
  • PHP 4 Features
  • PHP 5 Features
  • General Language Features of PHP

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    An Introduction to PHP - General Language Features of PHP
    ( Page 4 of 4 )

     

    Every user has his or her own specific reason for using PHP to implement a mission-critical application, although I find that such motives tend to fall into what I like to call the four pillars of PHP: Practicality, Power, Possibility, and Price.

    Practicality

    From the very start, the PHP language was created with practicality in mind. After all, Lerdorf’s original intention was not to design an entirely new language, but to resolve a problem that had no immediately applicable solution. Furthermore, much of PHP’s early evolution was not the result of the explicit intention to improve the language itself, but rather to increase its utility to the user. The result is what I like to call a minimalist language, in terms of what is required of the user, and in terms of the language’s syntactical requirements. For starters, a useful PHP script can consist of as little as one line; there is no need for the mandatory inclusion of libraries like in C. For example, the following represents a complete PHP script, the purpose of which is to output the current date, such as March 16, 2004:

    <?php echo date("F j, Y");?>

    Another example of the language’s penchant for compactness is its ability to nest functions. For example, I can effect numerous changes to a value on the same line by stacking functions in a particular order, in this case producing a pseudorandom string of five alphanumeric characters, such as “a3jh8”:

    $randomString = substr(md5(microtime()), 0, 5);

    PHP is a loosely-typed language, which also increases its practicality. For example, there is no need to explicitly create, typecast, or destroy a variable, although you are not prevented from doing so. PHP handles all of this for you, creating variables on the fly as they are called in a script, employing a best guess formula for automatically typecasting variables, and finally, automatically destroying variables and returning resources back to the system when the script completes. In these and many other respects, the language allows the developer to concentrate almost exclusively on the final goal (a working application), attempting to handle many of the administrative aspects of programming internally.

    Power

    In the earlier introduction to PHP 5, I alluded to the fact that the new version is more qualitative than quantitative in comparison to previous versions. Previous major versions were accompanied by enormous additions to PHP’s default libraries, to the tune of several hundred new functions per release. Presently, 113 libraries are available, collectively containing well over 1,000 functions. Although you’re likely aware of PHP’s ability to interface with databases, manipulate form information, and create pages dynamically, did you know that PHP can:

    • Create and manipulate Macromedia Flash, image, and Portable Document Format (PDF) files

    • Evaluate a password for guessability by comparing it to language dictionaries, and easily broken patterns

    • Communicate with the Lightweight Directory Access Protocol (LDAP)

    • Parse even the most complex of strings using both the POSIX and Perl-based regular expression libraries

    • Authenticate users against login credentials stored in flat files, databases, and even Microsoft’s Active Directory

    • Communicate with a wide variety of protocols, including IMAP, POP3, NNTP, and DNS, among others

    • Communicate with a wide array of credit-card processing solutions

    Of course, I’ll strive to cover as many of PHP’s interesting and useful features as possible in the coming chapters.

    Possibility

    PHP developers are rarely bound to any single implementation solution. On the contrary, a user can easily be overwhelmed by the number of choices offered by the language. For example, consider PHP’s array of database support options. Native support is offered for over twenty-five database products, including Adabas D, dBase, Empress, FilePro, FrontBase, Hyperwave, IBM DB2, Informix, Ingres, Interbase, mSQL, direct MS-SQL, MySQL, Oracle, Ovrimos, PostgreSQL, Solid, Sybase, Unix dbm, and Velocis. In addition, abstraction layer functions are available for accessing Berkeley DB-style databases. Finally, two database abstraction layers are available, one called the dbx module, and another via PEAR, titled the PEAR DB.

    PHP’s powerful string-parsing capabilities is another feature indicative of the possibility offered to users. In addition to more than eighty-five string manipulation functions, two distinct regular expression formats are supported POSIX and Perl-compatible. This flexibility not only offers users of differing skill sets the opportunity to immediately begin performing complex string operations, but also to quickly port programs of similar functionality (such as Perl and Python) over to PHP.

    Do you prefer a language that embraces functional programming? How about one that embraces the object-oriented paradigm? PHP offers comprehensive support for both. Although PHP was originally a solely functional language, the developers soon came to realize the importance of offering the popular OOP paradigm, and took the steps to implement an extensive solution.

    The recurring theme here is that PHP allows you to quickly capitalize on your current skill set with very little time investment. The examples set forth here are but a small sampling of this idea, which can be found repeatedly throughout the language.

    Price

    Since its inception, PHP has been without usage, modification, and redistribution restrictions. In recent years, software meeting such open licensing qualifications been referred to as open-source software. Open-source software and the Internet go together like bread and butter. Open-source projects like Sendmail, Bind, Linux, and Apache all play enormous roles in the ongoing operations of the Internet at large. Although the fact that open-source software is available free has been the characteristic most promoted by the media, several other characteristics are equally important if not more so:

    • Free of licensing restrictions imposed by most commercial products. Open Source software users are freed of the vast majority of licensing restrictions one would expect of commercial counterparts. Although some discrepancies do exist among license variants, users are largely free to modify, redistribute, and integrate the software into other products.

    • Open development and auditing process. Although there have been some incidents, open-source software has long enjoyed a stellar security record. Such high standards are a result of the open development and auditing process. Because the source code is freely available for examination by anyone who wants to, security holes and potential problems are rapidly found and fixed. This advantage was perhaps best summarized by open-source advocate Eric S. Raymond, who wrote, “Given enough eyeballs, all bugs are shallow.”

    • Everyone is free to participate. Development teams are not limited to a particular organization. Anyone who has the interest and the ability is free to join the project. The absence of member restrictions greatly enhances the talent pool for a given project, ultimately contributing to a higher quality product.

    Summary

    This chapter has provided a bit of foreshadowing about this wonderful language to which much of this book is devoted. We looked first at PHP’s history, before outlining version 4 and 5’s core features, setting the stage for later chapters.

    In Chapter 2, prepare to get your hands dirty, as you’ll delve into the PHP installation and configuration process. Although readers often liken most such chapters to scratching nails on a chalkboard, you can gain much from learning more about this process. Much like a professional cyclist or race car driver, the programmer with hands-on knowledge of the tweaking and maintenance process often holds an advantage over those without, by virtue of a better understanding of the software’s configurable behaviors and quirks. So grab a snack and snuggle up to your workstation; it’s time to build.



     
     
    >>> More PHP Articles          >>> More By Apress Publishing
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





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