PHP

Libraries

PHP has many libraries available for most common tasks in web database applications. In this section, we list most of the PHP libraries and point to other chapters in which selected libraries are discussed in more detail. For most libraries, we provide brief or only partial information.

The following is an alphabetically sorted list of the libraries:

Apache HTTP server functions

Includes a function to retrieve all HTTP headers, getallheaders( ).

Array functions

There are almost 50 functions to sort, merge, split, iteratively process, and return information about arrays. We discuss many of these functions in detail in Chapter 2.

BCMath arbitrary precision mathematics functions

A library of functions to perform high-precision calculations with large numbers.

Bzip compression functions

Tools to read and write files compressed with Julian Seward's highly effective compression algorithm; however, it's a bit slow compared to gzip.

Calendar functions

For conversion between various calendars, including the Jewish and Gregorian calendars, and for finding the date of Easter.

CCVS API functions

RedHat's solution for credit card transaction processing.

Character type functions

Additional string functions to check what characters are contained within a string. These can be used as a replacement for or in addition to the validation methods described in Chapter 7.

ClibPDF function library

Requires purchase of a license if used for commercial applications: The ClibPDF library accesses a set of C functions for creating Adobe PDF documents. The C library ClibPDF is available from http://www.fastio.com along with a licensing agreement.

CURL (client URL library) functions

Functions that communicate with resources using the FTP, gopher, HTTP, LDAP, Telnet, and other protocols.

Database functions

The MySQL library functions are discussed in detail in Chapter 4, with additional information on some functions in Chapter 5 and Chapter 6. Techniques for using the other DBMS libraries to connect to selected DBMSs are discussed briefly at the end of Chapter 4. Many other DBMS libraries are also available and detailed in the PHP manual; we don't discuss them here.

Date and time functions

The basics of date and time functions are described in Chapter 2. Examples are also discussed in Chapter 7.

Direct IO functions

A function library that accesses a file descriptor. The library is C-like in functionality, and C programmers will feel at home with the functions.

Directory functions

Changes directories in the filesystem, list files in a directory, etc.

Error handling and logging functions

Functions to change error reporting. Controlling the severity of PHP errors that are detected for debugging purposes is discussed in Chapter 2, and custom error handlers are discussed in Chapter 10.

Encryption functions

Selected encryption functions for producing cipher-text from plain text-and reversing the process-are discussed in Chapter 9.

eXtensible Markup Language (XML) functions

XML is a data format for structured document interchange, and this library provides tools to parse and retrieve components of XML documents.

Filesystem functions

Retrieves information about files, creates and modifies attributes of files, reads and writes files, and performs many other low-level file operations.

Forms Data Format functions

Tools to handle form data sent using the Forms Data Format (FDF) that's part of Adobe's PDF standard.

FTP

Functions that implement the File Transfer Protocol.

Functions functions

Seriously! A set of functions that inspects whether a function exists and returns details, such as the number of parameters to a function.

GNU teletext

A GNU project to internationalize programs by making substitution of program output messages in different languages easier.

GMP functions

More math functions for arbitrary-length integers using the GNU MP library; an alternative to the BCMath library described earlier in this section.

HTTP functions

The header( ) function creates HTTP headers in a response to a web browser. It is discussed and used in examples in Chapter 5 to Chapter 13. The function setcookie( ) sets a cookie in a web browser and is discussed in Chapter 8.

Hyperwave functions

This library offers functions to access the Hyperwave information system or document database. Use of the library requires purchase of the enterprise Hyperwave Information Server.

Image and graphics functions

Contains over 50 functions to draw images and render true-type fonts using the GD library.

IMAP, POP3, and NNTP functions

Network-oriented functions that use these protocols to retrieve and process email messages and Internet news postings.

IRC gateway

Functions to access an Internet relay chat (IRC) gateway. IRC is an Internet-base chat room.

Lightweight Directory Access Protocol (LDAP) functions

Tools to connect to and retrieve information from servers that store hierarchical directory information using LDAP.

Mail functions

Really one function, mail( ), to send an email to a destination; discussed in Chapter 12.

Mathematical functions

Functions to do just about anything to a number, but not to very large numbers (for those, use the BCMath or the GMP library); for example, the mathematical library includes trigonometry, random number generation, logarithm, and exponential functions. Many of these are discussed in Chapter 2.

Modular Calendar Access Library (MCAL) functions

Tools to access and manage an event calendar, such as a desktop diary, that is managed the underlying MCAL C library.

Ming functions for Flash

Tools that allows creation of Flash format movies.

mnoGoSearch functions

Functions that access the freely available text search engine mnoGoSearch.

Network functions

Networking libraries for high- and low-level network communications; for example, includes functions to check if a domain name exists, and convert numeric IP addresses to domain names and vice versa. A short background on networking can be found in Appendix B

Output control

Manages the buffering of output by PHP, allowing control of the PHP script engine's output.

PDF functions

Functions that create and manipulate Adobe Portable Document Format (PDF) documents.

POSIX functions

Functions that get information about processes, users, and other system-oriented aspects of functions defined in the IEEE 1003.1 (POSIX.1) standards document.

Program execution functions

These are discussed briefly in the context of securing a web database application in Chapter 5.

Pspell functions

Spelling functions that can not only check spelling but also make suggestions for corrections.

GNU Re-code functions

Functions that convert strings from one character set to another.

Regular expressions

Along with the string functions, an introduction to regular expression functions is covered in Chapter 2. (We cover only the native regular expression library that conforms to the POSIX 1003.2 standard, not the Perl-compatible regular expressions functions).

Satellite CORBA client extension functions

Functions that can access and use CORBA distributed objects.

Semaphore and shared memory functions

Functions based on Unix System V semaphores that allow multiple users controlled access to shared resources such as global variables in shared memory.

Session management functions

These functions are covered in detail in Chapter 8; an alternate session management module is discussed in Appendix D.

SHMOP shared memory functions

These functions duplicate the functionality of the System V shared memory tools described previously, but without some of the overheads in creating and managing shared memory spaces.

Simple Network Management Protocol (SNMP) functions

Functions that interact with SNMP agents to find available objects and to set those objects.

SWF Shockwave Flash functions

Another function library to create and use Flash format movies, with overlapping functionality to the Ming library described earlier.

Socket functions

Low-level network libraries to open, send, and receive data, and close network sockets (sockets are often loosely referred to as ports, which are discussed in Appendix B). Has some overlap with the network library, but the socket library is more concerned with low-level networking tasks.

String functions

The popular string functions are discussed in detail in Chapter 2.

URL (Uniform Resource Locator) functions

Tools that encode and decode MIME base64 encoded data used in HTTP and email, that encode and decode special characters from URLs, and that parse a URL and return its components.

Variable functions

Variable functions for determining and setting types are covered in Chapter 2.

Web Distributed Data eXchange (WDDX) libraries

Tools that process the XML-like format used in the open standard WDDX format, a standard that permits interchange of data between web-scripting languages such as PHP, ASP, and ColdFusion. More information about the WDDX Software Development Kit (SDK) can be found at http://www.openwddx.org.

XSLT (eXtensible Stylesheet Language Transformations) functions

XSLT is a language for transforming XML documents from one standard XML format to another.

YAZ functions

A library that implements the Z39.50 protocol for information retrieval. Z39.50 can be used, for example, to issue a remote search on a text database and to return results in a standard format.

YP/NIS functions

Tools that manage network functions remotely, such as password files.

Zlib compression functions

A set of functions to read and write gzip files compressed using the algorithms of Jean-Loup Gailly and Mark Adler.

Several of these function libraries are immature and are dynamically being improved and changed. New libraries emerge every month. Some libraries are outdated, and the projects that underlie them are inactive. However, for most libraries, several successful installations and uses have been reported, and the latest details can usually be found along with example code at the PHP web site in the annotated manual, http://www.php.net/manual/.

We have omitted any discussion of wholly redundant libraries, those used exclusively with Microsoft Windows, very new libraries, unstable libraries, and those libraries that aren't used in web applications.