Web Design Tutorials Made Easy


The Ever-Changing World of PHP |

In this article, I will take you through a brief history, current libraries, and PHP 5.

Then:

PHP has always been an ever-expanding web programming language, ever since it’s initial release on June 8th, 1995. PHP initially began as a bunch of CGI binaries written in C deemed “Personal Home Page Tools” (PHP tools). Two years later, Andi Gutmans and Zeev Suraski, the founders of Zend Technologies, took Rasmus Lerdorf‘s PHP-FI (PHP’s version 2) and rewrote the parser, giving birth to PHP 3 (now called Pre-Hypertext-Processor). In 1998, the parser was redesigned once again and named the Zend Engine, and the popular PHP 4 was released in the May of 2004.


It was this point in time that PHP was truly born. With this new, optimized, open-source, and highly modular backend engine, library after library was created, greatly increasing the capabilities of PHP 4. Now with another Zend Engine overhaul, PHP 5 debuts on July 13th, 2004.

Enough with the history lesson…

Currently Documented Libraries:

PHP is a 10-year-old language, and the functionality it has gained since version 2 is staggering (version 2’s manual and function list). So then, what’s new?

The old PHP gurus may be able to recall PHP-FI’s basic functionality a conglomeration of database, cookie, logic, math, file, image, and HTTP functions, among a few others. Here is the current list of official libraries, thanks to Wikipedia.

Of course, if you have recently checked out the PHP Extension Community Library recently, you would notice that the list of officially documented libraries scrapes the tip of the iceberg of what’s out there. For starters:
Apache: Only available when PHP is running as an Apache module. Allows for URI lookups, environment info, headers info, and virtual sub-requests and termination.

BCMath: For arbitrary precision mathematics, Binary Calculator Math supports numbers of any size and precision, represented as strings.

Bzip2: Handles .bz2 compressed files. Not compiled with PHP by default.

Calendars: The MCAL library has been moved to PECL since PHP 5. It’s the Calendar equivalent of IMAP for mailboxes. Supports many different types of streams.

CCVS: The depricated RedHat technology for processing credit card payments. It has now been replaced by MCVE.

COM: Microsoft’s “Component Object Module”. It is one of the main ways to glue applications together. You can now configure IIS, user accounts, or create an Excel Spreadsheet from your PHP scripts.

ClibPDF: Creates PDF documents from PHP.

cURL: Client URL allows you to connect and communicate with many different types of servers. Supports many common protocols such as FTP, HTTP, telnet, gopher, etc. Libcurl is not compiled into PHP by default.

Cybercash: Cybercash creditcard processing plugin. Cybercash was bought out by Verisign and now exists in a state of limbo at the PECL repository.

DB2: The gateway to the world of ODBC. Even connects to those who borrow the semantics of ODBC, regardless of the exact driver.

dBase: dBase support (dbf flatfile databases). Not recommended. Use a real SQL server instead. The functions in this library are extremely limited.

DBM: Yet another depricated database system. How useless…

dbx: A great database extraction layer tool. Interfaces with many common database systems. The replacement for DBM.

DB++: A German database library. Still experimental. Use at your own risk. Right now, it’s useless.

LDAP: The Lightweight Directory Access Protocol is here. Interfaces with “Directory Servers”. Not compiled by default.

DNS: All of your favorite Domain Name Services functions, and they’re compiled into the PHP core!!

DOMXML: Redone in PHP 4.3 to better comply with the standards, DOMXML is a nice library for dealing with XML files. Removed as of PHP 5 and put into PECL.

.NET: The other half of the COM library.

FrontBase: Another database system. As if we don’t have enough already…

filePro: database

FriBiDi: Support for the Unicode Bi-directional Algorithm. Library downloaded separately.

FTP: File Transfer Protocol. As old as dust, this extension is part of the PHP core.
gettext: Translation libraries. Pretty cool, but you have to install the libraries on your *nix OS before using.

GD Graphics: Image manipulation support for PHP. Great stuff.

GNU MPL: This multi-precision library is a great alternative to BCMath.

Hyperwave: …Um. Yeah. Hyperwave support. All I can say is “Product Sold Separately”. The library itself can be found in PECL.

iconv: Translates the character set of a string. May require some special installation.

IMAP, POP3, NNTP: The “you’ve got mail” libraries. Email protocols and support.

Sybase, Informix, Oracle, Ingres, Interbase: Relational Database Management Systems.

IRC Gateway: Streams XML data to thousands of concurrently connected users. In other words, it’s your portal to the famous Internet Relay Chat protocol.

Javax: An experimental java plug-in library.

Lotus Notes: This is just a little bit ridiculous. The Lotus Notes libraries have been moved to PECL as of PHP 5. Some people have too much time on their hands…

Mailparse: Still experimental. I would avoid it whenever possible.

MCAL: The Modular Calendar Access Library. MCAL and Calendars are actually one and the same thing.

Mcrypt: An excellent encryption library. Not compiled with PHP, though.

MCVE: The credit card processing library that replaced CCVS.

Mhash: Creates checksums, message digests and authentication codes, among other things.

Mimetype: Deprecated in favor of the fileinfo() function.

MS-SQL: The MSSQL server connection library. A rather popular database.

Ming: Creates Macromedia Flash files. One of my favorite plug-ins.

MonGoSearch: The interface to an awesome search engine by Lavatech. And I don’t use the word “awesome” very often…

mSQL: a database. Nothing special.

MySQL: The most commonly used database in conjunction with PHP. Built in to the PHP core.

Ncurses: A sort of terminal library more meant for use from the PHP CLI.

OpenSSL: Secure Socket Layer support.

PHP Data Objects: PDO is another database extraction layer.

PostgreSQL: Yet another database.

Printer: Windows platform-specific functions that interface with the server’s printer.

Pspell: Requires the aspell library. This allows you to check spelling. Very similar to the windows interface, except PHP style.

GNU Redline: The readine() functions provide editable command lines. Not a very useful library unless you’re into CLI.

Regular Expressions: RegExp is here in full force. Check out this article on RegExp for more info on how to use them.

Semaphores: In other words, a protected variable. Allows for restricted access to shared resources. Semaphores are built into the core of PHP.

SESAM: Mainframe database system support.

Session Handling: Ah, the wonderful world of sessions! PHP creates a special scope for sessions, and session handling functions are built into the PHP core.

Shared Memory: A set of shared memory functions. Meant for Unix systems.

SMTP: Simple Mail Transfer Protocol is another protocol that deals with email.

SNMP: Simple Network Management Protocol. Its implications are beyond my understanding.

Sockets: Low-level socket interface. May act as a socket server or client. PHP’s socket support is excellent.

SimpleXML: A library for PHP 5+ that allows for easy XML file manipulation.

SQLite: Yet another database.

Streams: As of PHP 4.3.0, streams have been built into the PHP core. Streams may be read or written to in a linear fashion, which is the basis for reading and writing in socket connections.

Tokenizer: PHP’s tokenizer functions allow you to write your own source modification tools without dealing with the language specifications at the lexical level.

WDDX: The Web Distributed Data Exchange is “protocol” for sending simple and complex types of data between different computers or languages, using an XML format. Originally developed in connection with Macromedia’s ColdFusion Server.

Win32 API: Interfaces with the Windows Operating System. Functions such as dl() allow you to dynamically load and make use of Windows DLLs. Experimental.

XML: More XML functions. I believe this is now deprecated.

XML-RPC: The experimental XML-RPC technology library.

NIS / (Yellow Pages): Allows for the network management of administrative files on *nix systems.

ZIP, zlib: Resources for compressing / decompressing data.
{mosgoogle}

What’s new in PHP 5?

1. OOP:
Since PHP 3, the Object Oriented model has barely been touched, until now. Before PHP 5, variables containing objects that were assigned to other variables, created copies of the object instead of passing along the handler reference. PHP 5 now passes the reference to an object instead of copying the object itself. This will probably save a few headaches and uses of the ‘&’ sign in your code. PHP 5 can still make a copy of the original object variable, but this must be specified by use of the clone keyword.

2. Protected access:
PHP 5 also introduces the public, private, and protected access modifiers for methods and variables. This allows for an extra layer of security when working with classes. public may be changed outside or inside of a class, private by functions or methods in that class only, and protected I’m not sure about.

3. __construct():
Instead of naming the constructor method the same thing as your class, you may now use __construct() as the name of your constructor method.

class MyClass {
        function __construct() {
        print "Inside constructor";
        }
        }

4. __destruct():
This method runs whenever an object is destroyed, like at the end of script execution.

class MyClass {
        function __destruct() {
        print "Destroying Object. Great for saving object data.";
        }
        }

5. __get() and __set():
When in an object, __get() will be called when reading the value of an undefined property, giving you a chance to do something and return a value. __set() is called when you try to change that same property’s value.

6. Interfaces:
A class may have one parent only, but interfaces allow you implement other functions.

interface Display {
        function display();
        }
 
        class Circle implements Display {
        function display() {
        print "Displaying circle\n";
        }
        }

7. “instance of” operator:
Object relationship checking. Also means that is_a() is now deprecated.

if ($obj instance of Circle) {
        print '$obj is a Circle';
        }

8. Final declaration:
You may now declare classes or class methods as final, making them non-inheritable.

9. __clone() method:
To clone an object in PHP 5, the clone keyword must be specified. The __clone() method will be called after the object is cloned.

class MyClass {
        function __clone() {
        print "Object is being cloned";
        }
        }
        $obj = new MyClass();
        clone $obj;

10. Class Constants:
Class constants may now be defined, and are referenced by the class. By using:
MyClass::CONSTANT_NAME

11. Static and Abstract:
Good old static may be used on class members and methods. abstract allows you to define methods and classes that may not be instantiated, but only inherited.

12. “Dereferencing” objects returned by methods:
Objects returned by a method may now be directly referenced.
PHP 4:

$dummy = $obj->method();
        $dummy->method2();

PHP 5:

$obj->method()->method2();

13. __autoload():
Many developers break their classes up into separate files, thus having to include every single class file before use. With __autoload(), that is no longer necessary.

function __autoload($class_name) {
        include_once($class_name . "php");
        }

This function gives you one last chance to find the class definition before PHP bails out with an error.

14. Exception Handling:
try, catch, and throw are now part of PHP 5.

15. foreach with references:
Before PHP 5, you could not iterate through an array and modify it’s values. In PHP 5, you can mark the loop with the ‘&’ (reference) sign, allowing you to change the values of the array your iterating.

foreach ($array as &$value) {
        if ($value === "NULL") {
        $value = NULL;
        }
        }

16. Default values for referenced parameters:
By using the ‘&’ (reference) sign in front of your parameter definition, you can modify the referencing variable instead of the in-method copy.
function my_func(&$arg = null) {

If you’d like more info on PHP5, check out the website at http://zend.com/php5/.

Code Snippets taken from http://zend.com/php5/andi-book-excerpt.php

by Kenaniah Cerny

No Responses to 'The Ever-Changing World of PHP'

Be the first to comment on this post!

Leave a Reply

*required

*required / not published

Categories
Archives