Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2665

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Loads a PHP extension at runtime</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.cli-set-process-title.html">cli_set_process_title</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.extension-loaded.html">extension_loaded</a></div>
 <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.dl" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dl</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">dl</span> &mdash; <span class="dc-title">Loads a PHP extension at runtime</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.dl-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>dl</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$library</code></span>
   )</div>

  <p class="para rdfs-comment">
   Loads the PHP extension given by the parameter
   <em><code class="parameter">library</code></em>.
  </p>
  <p class="para">
   Use  <span class="function"><a href="function.extension-loaded.html" class="function">extension_loaded()</a></span> to test whether a given
   extension is already available or not. This works on both built-in
   extensions and dynamically loaded ones (either through <var class="filename">php.ini</var> or
    <span class="function"><strong>dl()</strong></span>).
  </p>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="simpara">
    This function has been removed from some SAPIs in PHP 5.3.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.dl-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">library</code></em></span>
     <dd>

      <p class="para">
       This parameter is <em class="emphasis">only</em> the filename of the
       extension to load which also depends on your platform. For example,
       the <a href="ref.sockets.html" class="link">sockets</a> extension (if compiled
       as a shared module, not the default!) would be called 
       <var class="filename">sockets.so</var> on Unix platforms whereas it is called
       <var class="filename">php_sockets.dll</var> on the Windows platform.
      </p>
      <p class="para">
       The directory where the extension is loaded from depends on your
       platform:
      </p>
      <p class="para">
       Windows - If not explicitly set in the <var class="filename">php.ini</var>, the extension is
       loaded from <var class="filename">C:\php4\extensions\</var> (PHP 4) or 
       <var class="filename">C:\php5\</var> (PHP 5) by default.
      </p>
      <p class="para">
       Unix - If not explicitly set in the <var class="filename">php.ini</var>, the default extension
       directory depends on
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          whether PHP has been built with <em>--enable-debug</em>
          or not
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          whether PHP has been built with (experimental) ZTS (Zend Thread Safety)
          support or not
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          the current internal <em>ZEND_MODULE_API_NO</em> (Zend
          internal module API number, which is basically the date on which a
          major module API change happened, e.g. <em>20010901</em>)
         </span>
        </li>
       </ul>
       Taking into account the above, the directory then defaults to
       <em>&lt;install-dir&gt;/lib/php/extensions/ &lt;debug-or-not&gt;-&lt;zts-or-not&gt;-ZEND_MODULE_API_NO</em>,
       e.g.
       <var class="filename">/usr/local/php/lib/php/extensions/debug-non-zts-20010901</var>
       or
       <var class="filename">/usr/local/php/lib/php/extensions/no-debug-zts-20010901</var>.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.dl-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. If the functionality of loading modules is not available
   or has been disabled (either by setting
   <a href="info.configuration.html#ini.enable-dl" class="link">enable_dl</a> off or by enabling <a href="ini.sect.safe-mode.html#ini.safe-mode" class="link">safe mode</a>
   in <var class="filename">php.ini</var>) an <strong><code>E_ERROR</code></strong> is emitted
   and execution is stopped. If  <span class="function"><strong>dl()</strong></span> fails because the
   specified library couldn&#039;t be loaded, in addition to <strong><code>FALSE</code></strong> an
   <strong><code>E_WARNING</code></strong> message is emitted.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.dl-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-482">
    <p><strong>Example #1  <span class="function"><strong>dl()</strong></span> examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Example&nbsp;loading&nbsp;an&nbsp;extension&nbsp;based&nbsp;on&nbsp;OS<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">extension_loaded</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlite'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">strtoupper</span><span style="color: #007700">(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">PHP_OS</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">))&nbsp;===&nbsp;</span><span style="color: #DD0000">'WIN'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">dl</span><span style="color: #007700">(</span><span style="color: #DD0000">'php_sqlite.dll'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">dl</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlite.so'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Or,&nbsp;the&nbsp;PHP_SHLIB_SUFFIX&nbsp;constant&nbsp;is&nbsp;available&nbsp;as&nbsp;of&nbsp;PHP&nbsp;4.3.0<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">extension_loaded</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlite'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$prefix&nbsp;</span><span style="color: #007700">=&nbsp;(</span><span style="color: #0000BB">PHP_SHLIB_SUFFIX&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #DD0000">'dll'</span><span style="color: #007700">)&nbsp;?&nbsp;</span><span style="color: #DD0000">'php_'&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">dl</span><span style="color: #007700">(</span><span style="color: #0000BB">$prefix&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'sqlite.'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">PHP_SHLIB_SUFFIX</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.dl-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
         <span class="function"><strong>dl()</strong></span> is now disabled in some SAPIs due to
        stability issues.  The only SAPIs that
        allow  <span class="function"><strong>dl()</strong></span> are CLI and Embed.  Use
        the <a href="ini.core.html#ini.extension" class="link">Extension Loading
        Directives</a> instead.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.dl-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
     <span class="function"><strong>dl()</strong></span> is <em class="emphasis">not</em> supported when
    PHP is built with ZTS support. Use
    the <a href="ini.core.html#ini.extension" class="link">Extension Loading
    Directives</a> instead.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
     <span class="function"><strong>dl()</strong></span> is case sensitive on Unix platforms.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is disabled when PHP is running in <a href="features.safe-mode.html" class="link">safe mode</a>.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.dl-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="ini.core.html#ini.extension" class="link">Extension Loading Directives</a></li>
    <li class="member"> <span class="function"><a href="function.extension-loaded.html" class="function" rel="rdfs-seeAlso">extension_loaded()</a> - Find out whether an extension is loaded</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.cli-set-process-title.html">cli_set_process_title</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.extension-loaded.html">extension_loaded</a></div>
 <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>