<HTML ><HEAD ><TITLE >Extension Possibilities</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Extending PHP 4.0" HREF="zend.html"><LINK REL="PREVIOUS" TITLE="Overview" HREF="zend.overview.html"><LINK REL="NEXT" TITLE="Built-in Modules" HREF="zend.possibilities.builtin.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="chapter" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="zend.overview.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="zend.possibilities.builtin.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="zend.possibilities" >Chapter 25. Extension Possibilities</A ></H1 ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="zend.possibilities.html#zend.possibilities.external" >External Modules</A ></DT ><DT ><A HREF="zend.possibilities.builtin.html" >Built-in Modules</A ></DT ><DT ><A HREF="zend.possibilities.engine.html" >The Zend Engine</A ></DT ></DL ></DIV ><P > As shown in <A HREF="zend.overview.html#fig.internal-struct" >Figure 24-1</A > above, PHP can be extended primarily at three points: external modules, built-in modules, and the Zend engine. The following sections discuss these options. </P ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zend.possibilities.external" ></A >External Modules</H1 ><P > External modules can be loaded at script runtime using the function <A HREF="function.dl.html" ><B CLASS="function" >dl()</B ></A >. This function loads a shared object from disk and makes its functionality available to the script to which it's being bound. After the script is terminated, the external module is discarded from memory. This method has both advantages and disadvantages, as described in the following table: <DIV CLASS="informaltable" ><A NAME="AEN99487" ></A ><P ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" >Advantages</TD ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" >Disadvantages</TD ></TR ><TR ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" > External modules don't require recompiling of PHP. </TD ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" > The shared objects need to be loaded every time a script is being executed (every hit), which is very slow. </TD ></TR ><TR ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" > The size of PHP remains small by "outsourcing" certain functionality. </TD ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" > External additional files clutter up the disk. </TD ></TR ><TR ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" > </TD ><TD WIDTH="50%" ALIGN="LEFT" VALIGN="MIDDLE" > Every script that wants to use an external module's functionality has to specifically include a call to <A HREF="function.dl.html" ><B CLASS="function" >dl()</B ></A >, or the <TT CLASS="literal" >extension</TT > tag in <TT CLASS="filename" >php.ini</TT > needs to be modified (which is not always a suitable solution). </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV > To sum up, external modules are great for third-party products, small additions to PHP that are rarely used, or just for testing purposes. To develop additional functionality quickly, external modules provide the best results. For frequent usage, larger implementations, and complex code, the disadvantages outweigh the advantages. </P ><P > Third parties might consider using the <TT CLASS="literal" >extension</TT > tag in <TT CLASS="filename" >php.ini</TT > to create additional external modules to PHP. These external modules are completely detached from the main package, which is a very handy feature in commercial environments. Commercial distributors can simply ship disks or archives containing only their additional modules, without the need to create fixed and solid PHP binaries that don't allow other modules to be bound to them. </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="zend.overview.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="zend.possibilities.builtin.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Overview</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="zend.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Built-in Modules</TD ></TR ></TABLE ></DIV ></BODY ></HTML >