-
Notifications
You must be signed in to change notification settings - Fork 50
/
dl.xml
226 lines (216 loc) · 6.77 KB
/
dl.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 8373b869c3a0726f809cf4ba0b011ea547221033 Maintainer: seros Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.dl" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>dl</refname>
<refpurpose>Carga una extensión de PHP durante la ejecución</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>dl</methodname>
<methodparam><type>string</type><parameter>library</parameter></methodparam>
</methodsynopsis>
<para>
Carga la extensión PHP dada por el parámetro
<parameter>library</parameter>.
</para>
<para>
Utilice la función <function>extension_loaded</function> para comprobar si la extensión
ya está cargada o no. Funciona tanto para extensiones ya integradas en PHP o
para extensiones que se han cargado dinámicamente (ya sea a través de &php.ini; o
<function>dl</function>).
</para>
<warning>
<simpara>
Esta función ha sido eliminada de la mayoría de las SAPI en PHP 5.3.0, y
de PHP-FPM en PHP 7.0.0.
</simpara>
</warning>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>library</parameter></term>
<listitem>
<para>
Este parámetro es <emphasis>solamente</emphasis> el fichero de la
extensión a cargar el cual depende del sistema operativo. Por ejemplo,
la extensión <link linkend="ref.sockets">sockets</link> (si se compila
como librería, no como parte de PHP) Se llamará
<filename>sockets.so</filename> en sistemas Unix mientras que en Windows
se llamará <filename>php_sockets.dll</filename>.
</para>
<para>
El directorio desde donde la extensión será cargada también depende
del sistema operativo:
</para>
<para>
En Windows - a no ser que se defina explicitamente en &php.ini;, la extensión
será cargada por defecto desde <filename>C:\php4\extensions\</filename> (PHP4) o
<filename>C:\php5\</filename> en (PHP 5).
</para>
<para>
Unix - a no ser que se defina en &php.ini;, el directorio de extensiones por defecto
depende de
<itemizedlist>
<listitem>
<simpara>
Si PHP fué compilado con la opción <literal>--enable-debug</literal>
o no
</simpara>
</listitem>
<listitem>
<simpara>
Si PHP fué comiplado con soporte (experimental) ZTS (Zend Thread Safety)
o no
</simpara>
</listitem>
<listitem>
<simpara>
El módulo interno actual <literal>ZEND_MODULE_API_NO</literal> (Número
interno del API Zend, que es básicamente la fecha en que se produjo
un cambio de versión, p.ej. <literal>20010901</literal>)
</simpara>
</listitem>
</itemizedlist>
Teniendo esto en cuenta el directorio por defecto será
<literal><install-dir>/lib/php/extensions/ <debug-or-not>-<zts-or-not>-ZEND_MODULE_API_NO</literal>,
p.ej.
<filename>/usr/local/php/lib/php/extensions/debug-non-zts-20010901</filename>
o
<filename>/usr/local/php/lib/php/extensions/no-debug-zts-20010901</filename>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success; Si la funcionalidad de cargar módulos no está disponible
o ha sido deshabilitada (ya sea activando
<link linkend="ini.enable-dl">enable_dl</link> off
en &php.ini;) Se producirá un <constant>E_ERROR</constant>
y se parará la ejecucción de PHP. Si <function>dl</function> falló porque la
librería especificacda no pudo cargarse a demás de &false; se
producirá un mensaje <constant>E_WARNING</constant>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Ejemplos de <function>dl</function></title>
<programlisting role="php">
<![CDATA[
<?php
// En este ejemplo se carga una extensión u otra dependiendo del sistema operativo
if (!extension_loaded('sqlite')) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
dl('php_sqlite.dll');
} else {
dl('sqlite.so');
}
}
// O si la constante PHP_SHLIB_SUFFIX está disponible desde PHP 4.3.0
if (!extension_loaded('sqlite')) {
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.0.0</entry>
<entry>
<function>dl</function> está deshabilitado en PHP-FPM.
</entry>
</row>
<row>
<entry>5.3.9</entry>
<entry>
<function>dl</function> está deshabilitado en PHP-FPM, aunque se desaconseja.
</entry>
</row>
<row>
<entry>5.3.0</entry>
<entry>
<function>dl</function> está desactivado en algunos módulos SAPI por problemas
de estabilidad. Los únicos modulos SAPI que
permiten <function>dl</function> son: CLI, CGI and Embed. En su lugar usar
las directivas <link linkend="ini.extension">Directivas de carga
de extensiones</link>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
<function>dl</function> <emphasis>no</emphasis> se soporta cuando
PHP es compilado con soporte ZTS. Use
en su lugar <link linkend="ini.extension">Directivas de carga
de extensiones</link> instead.
</para>
</note>
<note>
<para>
<function>dl</function> es sensible a mayúsculas en sistemas Unix.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="ini.extension">Directivas de cargas de extensiones</link></member>
<member><function>extension_loaded</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->