RE: [PHP-ES] Consulta sobre includes/requires y funciones

From: Date: Mon, 09 Sep 2002 15:56:49 +0000
Subject: RE: [PHP-ES] Consulta sobre includes/requires y funciones
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-26689@lists.php.net to get a copy of this message
NO NO NO NO !!!!! AMIGOS, la diferencia entre include y require es la siguiente: (en Php4) require importa un archivo, por mas que este dentro de un bloque de codigo que nunca sea ejecutado... ejmplo: if (1==2) { require "file.inc." } esto siempre dara false, PERO EL REQUIRE igual se ejecutara. Si aqui tuviesemos include en lugar de require, no seria el caso. (Te paso el parrafo del libro que lo extrai, mas abajo) Un abrazo mac ================================= include( ) and require( ) These commands are very similar and can usually be used interchangeably. However, you should know what distinguishes the two, as at times using the wrong one can cause problems. The require()command imports the content of the specified file even if the file is not used. This means, for starters, that even if the require()is within an if block that tests false, the outside file will still be included. You can probably deduce that this isn’t such a big deal because code within a block that tests false won’t be executed. However, it does take time for PHP to do the import, and there’s no need to add execution time to your script by placing a require within an if block that could test false. The include()command will work better in a situation like the one above. An include()command will be executed each time it is encountered within a script. > -----Mensaje original----- > De: Rafael Salazar [mailto:rsalazar@ucol.mx] > Enviado el: Lunes, 09 de Septiembre de 2002 03:17 p.m. > Para: lista@phpes.com > Asunto: Re: [PHP-ES] Consulta sobre includes/requires y funciones > > > At 13:29 09/09/2002 -0300, you wrote: > >Tengo un archivo funciones.inc.php , donde tengo un grupo de > funciones que > >normalmente uso, > >F1; F2; F3 ; F4; etc > > > >pero supongamos como la biblioteca esta es bastante extensa y solo deseo > >incluir una funcion en particular la F2 (y no quiero replicar > la funcion > >F2 nuevamente), por ejemplo, es posible indicar en el > >include/requiere("funciones.inc.php"); que solo llame a la F2 algo como > >"funciones.inc.php#F2" ??? pra no incluir todo el paquete completo? > > Según tengo entendido, ésa es la diferencia entre include() y > require(), que con include "metes" todo el archivo en el tuyo, y con > require sólo aquello que llamas (en este caso, las funciones que invocas, > como F2). > > A manera de nota: te diría que no te tomes tan en serio lo que > alguien te pueda decir en un mensaje de correo, pero aquí en ocasiones > llueven discusiones (y sin sentido muchísimas de ellas), por lo que no > sería mala idea pedir respuestas por privado, a ver si así se dan > cuenta de > la idea de la lista, que es _compartir_ el conocimiento, no "regañar" o > discutir con la gente. > > > En fín, suerte, > Rafael. > > P.D. Disculpa el "fart" cerebral, no lo vuelvo a hacer :P > > > --------------------------------------------------------------------- > Archivo On-line: http://www.phpes.com/ > via news: news://news.phpes.com/ > Manual PHP en español: http://www.php.net/manual/es/ > Para dar de baja la suscripción, mande un mensaje a: > lista-unsubscribe@phpes.com > †Þ®Û«ië)yȚ•×¥h*)h˧v&¥uéZ@ ŠÞh–©Ÿm4ÚÉhzv†Šzš+µë†Ûiÿö«²š+¶Ìš†Š¢o߉ö°¢¹]rê

« previous php.general.es (#26689) next »