ebook img

Manual de PHP – Stig Sæther Bakken, Alexander Aulbach y otros PDF

1719 Pages·2003·3.13 MB·German
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Manual de PHP – Stig Sæther Bakken, Alexander Aulbach y otros

Manual de PHP Stig Sæther Bakken Alexander Aulbach Egon Schmid Jim Winstead Lars Torben Wilson Rasmus Lerdorf Andrei Zmievski Jouni Ahto Editado por Rafael Martínez (Coordinador) Víctor Fernández Leonardo Boshell 08-07-2002 Copyright © 1997, 1998, 1999, 2000, 2001, 2002 por por el Grupo de documentación de PHP Copyright Este manual es © Copyright 1997, 1998, 1999, 2000, 2001, 2002 por el Grupo de documentación de PHP. Los miembros de este grupo se encuentran listados en la primera página de este manual. Este manual puede ser redistribuido bajo los términos de la "GNU General Public License" publicada por la "Free Software Foundation"; tanto bajo la versión 2 de esta licencia o bajo versiones posteriores. La sección ’Extendiendo PHP 4.0’ de este manual es copyright © 2000 por Zend Technologies, Ltd. Este material puede ser distribuido solamente bajo los terminos y condiciones de la Open Publication License, v1.0 ó posterior (la última versión está disponible en http://www.opencontent.org/openpub/). ManualdePHP porStigSætherBakken,AlexanderAulbach,EgonSchmid,JimWinstead,LarsTorbenWilson,RasmusLerdorf, AndreiZmievski,yJouniAhto por EditadoporRafaelMartínez(Coordinador) EditadoporVíctorFernández EditadoporLeonardoBoshell Publicado08-07-2002 Copyright©1997,1998,1999,2000,2001,2002porporelGrupodedocumentacióndePHP Copyright Estemanuales©Copyright1997,1998,1999,2000,2001,2002porelGrupodedocumentacióndePHP.Los miembrosdeestegruposeencuentranlistadosenlaprimerapáginadeestemanual. Estemanualpuedeserredistribuidobajolostérminosdela"GNUGeneralPublicLicense"publicadaporla"Free SoftwareFoundation";tantobajolaversión2deestalicenciaobajoversionesposteriores. Lasección’ExtendiendoPHP4.0’deestemanualescopyright©2000porZendTechnologies,Ltd.Estematerial puedeserdistribuidosolamentebajolosterminosycondicionesdelaOpenPublicationLicense,v1.0óposterior(la últimaversiónestádisponibleenhttp://www.opencontent.org/openpub/). Tabla de contenidos Prefacio........................................................................................................................................................i I.ConceptosBásicos..................................................................................................................................1 1.Introducción...................................................................................................................................1 QuéesPHP?.............................................................................................................................2 QuésepuedehacerconPHP?..................................................................................................2 2.Instalación......................................................................................................................................5 Bajándoselaúltimaversión......................................................................................................6 InstalaciónensistemasUNIX..................................................................................................6 InstruccionesRápidasdeInstalación(VersiónMódulodeApache)..............................6 Configuración..................................................................................................................7 MódulodelApache.........................................................................................................7 Módulofhttpd.................................................................................................................7 CGIversion.....................................................................................................................7 OpcionesdesoporteparaBasedeDatos........................................................................8 AdabasD...............................................................................................................8 dBase.....................................................................................................................8 filePro....................................................................................................................8 mSQL....................................................................................................................8 MySQL..................................................................................................................9 iODBC...................................................................................................................9 OpenLinkODBC...................................................................................................9 Oracle....................................................................................................................9 PostgreSQL...........................................................................................................9 Solid....................................................................................................................10 Sybase..................................................................................................................10 Sybase-CT...........................................................................................................10 Velocis.................................................................................................................10 UnalibreríaamedidadeODBC.........................................................................11 ODBCUnificado.................................................................................................11 LDAP...................................................................................................................11 Otrasopcionesdeconfiguración...................................................................................11 --with-mcrypt=DIR.............................................................................................12 --enable-sysvsem.................................................................................................12 --enable-sysvshm.................................................................................................12 --with-xml............................................................................................................12 --enable-maintainer-mode...................................................................................12 --with-system-regex.............................................................................................12 --with-config-file-path.........................................................................................13 --with-exec-dir.....................................................................................................13 --enable-debug.....................................................................................................13 --enable-safe-mode..............................................................................................13 --enable-track-vars...............................................................................................13 --enable-magic-quotes.........................................................................................14 --enable-debugger................................................................................................14 --enable-discard-path...........................................................................................14 iv --enable-bcmath...................................................................................................14 --enable-force-cgi-redirect..................................................................................14 --disable-short-tags..............................................................................................15 --enable-url-includes...........................................................................................15 --disable-syntax-hl...............................................................................................15 CPPFLAGSyLDFLAGS...................................................................................15 Construyendo................................................................................................................16 Probando.......................................................................................................................16 Comprobandolavelocidad...........................................................................................16 InstalaciónensistemasWindows95/98/NT...........................................................................16 PasosGeneralesdeInstalación.....................................................................................16 Windows95/98/NTyPWS/IIS3..................................................................................17 WindowsNTeIIS4.....................................................................................................18 Windows9x/NTyApache1.3.x...................................................................................19 OmniHTTPd2.0b1paraWindows..............................................................................19 MódulosdelPHP..........................................................................................................19 ¿Problemas?............................................................................................................................20 LealasPMF(FAQ).......................................................................................................20 Informesdeerror...........................................................................................................20 Otrosproblemas............................................................................................................20 3.Configuración...............................................................................................................................22 Elarchivodeconfiguración....................................................................................................23 DirectivasGeneralesdeConfiguración.........................................................................23 DirectivasdeConfiguracióndeCorreo.........................................................................27 DirectivasdeConfiguracióndeModoSeguro..............................................................28 DirectivasdeConfiguracióndelDebugger...................................................................28 DirectivasdeCargadeExtensiones..............................................................................28 DirectivasdeConfiguracióndeMySQL.......................................................................29 DirectivasdeConfiguracióndemSQL.........................................................................29 DirectivasdeConfiguracióndePostgres......................................................................29 SESAMConfigurationDirectives.................................................................................30 DirectivasdeConfiguracióndeSybase........................................................................30 DirectivasdeConfiguracióndeSybase-CT..................................................................31 DirectivasdeConfiguracióndeInformix......................................................................32 DirectivasdeConfiguracióndeMatemáticaBC...........................................................33 DirectivasdeConfiguracióndeCapacidadesdelosNavegadores................................33 DirectivasUnificadasdeConfiguracióndeODBC.......................................................33 4.Seguridad......................................................................................................................................35 BinariosCGI...........................................................................................................................36 Posiblesataques............................................................................................................36 Caso1:solamentesesirvenficherospublicos..............................................................37 Caso2:usando--enable-force-cgi-redirect...................................................................37 Caso3:Usandodoc_rootoruser_dir............................................................................37 Caso4:AnalizadorPHPfueradelarbolweb...............................................................38 ModuloApache......................................................................................................................38 v II.ReferenciadelLenguaje.....................................................................................................................40 5.Síntaxisbásica..............................................................................................................................40 SaliendodeHTML.................................................................................................................41 Separacióndeinstrucciones...................................................................................................42 Comentarios............................................................................................................................43 6.Types............................................................................................................................................44 Enteros....................................................................................................................................45 Númerosenpuntoflotante......................................................................................................45 Cadenas...................................................................................................................................45 Conversióndecadenas..................................................................................................47 Arrays.....................................................................................................................................48 Arraysunidimensionales...............................................................................................48 ArraysMultidimensionales...........................................................................................49 Objetos....................................................................................................................................50 InicializacióndeObjetos...............................................................................................51 Typejuggling..........................................................................................................................51 Forzadodetipos............................................................................................................52 7.Variables.......................................................................................................................................54 ConceptosBásicos..................................................................................................................55 Variablespredefinidas.............................................................................................................56 VariablesdeApache......................................................................................................56 Variablesdeentorno......................................................................................................58 VariablesdePHP...........................................................................................................58 Ambitodelasvariables..........................................................................................................59 Variablesvariables..................................................................................................................61 VariablesexternasaPHP........................................................................................................62 FormulariosHTML(GETyPOST).............................................................................62 IMAGESUBMITvariablenames.......................................................................63 CookiesHTTP..............................................................................................................63 Variablesdeentorno......................................................................................................64 Puntosenlosnombresdevariablesdeentrada.............................................................64 Determinandolostiposdevariables.............................................................................65 8.Constantes....................................................................................................................................66 Sintaxis...................................................................................................................................67 Constantespredefinidas..........................................................................................................68 9.Expresiones..................................................................................................................................69 10.Operadores.................................................................................................................................73 OperadoresAritméticos..........................................................................................................74 OperadoresdeAsignación......................................................................................................74 OperadoresBitabit................................................................................................................74 OperadoresdeComparación..................................................................................................75 Operadordeejecución............................................................................................................76 OperadoresdeIncremento/decremento..................................................................................76 OperadoresLógicos................................................................................................................77 PrecedenciadeOperadores.....................................................................................................77 OperadoresdeCadenas..........................................................................................................78 11.EstructurasdeControl................................................................................................................80 if............................................................................................................................................81 vi else.......................................................................................................................................81 elseif...................................................................................................................................82 SintaxisAlternativadeEstructurasdeControl.......................................................................82 while.....................................................................................................................................83 do..while.............................................................................................................................84 for..........................................................................................................................................85 foreach.................................................................................................................................86 break.....................................................................................................................................88 continue...............................................................................................................................89 switch...................................................................................................................................90 require()..................................................................................................................................92 include()..................................................................................................................................93 require_once().........................................................................................................................96 include_once()........................................................................................................................98 12.Funciones.................................................................................................................................100 Funcionesdefinidasporelusuario.......................................................................................101 Parámetrosdelasfunciones.................................................................................................101 Pasarparámetrosporreferencia..................................................................................101 Parámetrospordefecto...............................................................................................102 Listadelongitudvariabledeparámetros....................................................................103 Devolvervalores...................................................................................................................103 old_function....................................................................................................................104 Funcionesvariable................................................................................................................104 13.ClasesyObjetos.......................................................................................................................106 class...................................................................................................................................107 14.ReferencesExplained...............................................................................................................110 WhatReferencesAre............................................................................................................111 WhatReferencesDo.............................................................................................................111 WhatReferencesAreNot.....................................................................................................112 PassingbyReference............................................................................................................112 ReturningReferences...........................................................................................................113 UnsettingReferences............................................................................................................114 SpottingReferences..............................................................................................................114 globalReferences.....................................................................................................114 $this..........................................................................................................................115 III.Características.................................................................................................................................116 15.Manejandoerrores....................................................................................................................116 16.Creandoymanipulandoimágenes...........................................................................................121 17.AutentificaciónHTTPconPHP...............................................................................................123 18.Cookies.....................................................................................................................................126 19.Manejodeenvíodeficheros.....................................................................................................128 EnvíodearchivosconelmétodoPOST...............................................................................129 Errorescomunes...................................................................................................................131 Envíodemultiplesficheros..................................................................................................131 SoportedelmétodoPUT......................................................................................................132 20.Usandoarchivosremotos.........................................................................................................134 21.Manejandoconexiones.............................................................................................................137 vii 22.Conexionespersistentesabasesdedatos.................................................................................139 23.ModoSeguro(SafeMode).......................................................................................................142 Funcionesrestringidas/inhabilitadasporModoSeguro.......................................................144 24.UsingPHPfromthecommandline.........................................................................................149 IV.ReferenciadelasFunciones...........................................................................................................162 I.FuncionesespecíficasdeApache................................................................................................162 apache_child_terminate........................................................................................................163 apache_lookup_uri...............................................................................................................163 apache_note..........................................................................................................................164 apache_setenv.......................................................................................................................164 ascii2ebcdic..........................................................................................................................164 ebcdic2ascii..........................................................................................................................164 getallheaders.........................................................................................................................165 virtual....................................................................................................................................165 II.Funcionesdematrices...............................................................................................................167 array_change_key_case........................................................................................................169 array_chunk..........................................................................................................................169 array_count_values...............................................................................................................170 array_diff..............................................................................................................................171 array_fill...............................................................................................................................172 array_filter............................................................................................................................172 array_flip...............................................................................................................................174 array_intersect......................................................................................................................174 array_key_exists...................................................................................................................175 array_keys.............................................................................................................................175 array_map.............................................................................................................................176 array_merge_recursive.........................................................................................................179 array_merge..........................................................................................................................180 array_multisort.....................................................................................................................181 array_pad..............................................................................................................................182 array_pop..............................................................................................................................183 array_push............................................................................................................................183 array_rand.............................................................................................................................184 array_reduce.........................................................................................................................185 array_reverse........................................................................................................................185 array_search..........................................................................................................................186 array_shift.............................................................................................................................186 array_slice.............................................................................................................................187 array_splice...........................................................................................................................188 array_sum.............................................................................................................................189 array_unique.........................................................................................................................190 array_unshift.........................................................................................................................191 array_values..........................................................................................................................192 array_walk............................................................................................................................192 array......................................................................................................................................193 arsort.....................................................................................................................................194 asort......................................................................................................................................194 viii compact.................................................................................................................................195 count.....................................................................................................................................195 current...................................................................................................................................196 each.......................................................................................................................................196 end........................................................................................................................................198 extract...................................................................................................................................198 in_array.................................................................................................................................199 key........................................................................................................................................200 krsort.....................................................................................................................................200 ksort......................................................................................................................................201 list.........................................................................................................................................201 natcasesort............................................................................................................................202 natsort...................................................................................................................................202 next.......................................................................................................................................203 pos.........................................................................................................................................204 prev.......................................................................................................................................204 rango.....................................................................................................................................204 reset.......................................................................................................................................205 rsort.......................................................................................................................................205 shuffle...................................................................................................................................205 sizeof.....................................................................................................................................206 sort........................................................................................................................................206 uasort....................................................................................................................................206 uksort....................................................................................................................................207 usort......................................................................................................................................207 III.FuncionesAspell[deprecated].................................................................................................209 aspell_check-raw..................................................................................................................210 aspell_check.........................................................................................................................210 aspell_new............................................................................................................................210 aspell_suggest.......................................................................................................................211 IV.FuncionesmatemáticasdeprecisiónarbitrariaBCMath.........................................................212 bcadd.....................................................................................................................................213 bccomp.................................................................................................................................213 bcdiv.....................................................................................................................................213 bcmod...................................................................................................................................213 bcmul....................................................................................................................................213 bcpow....................................................................................................................................214 bcscale..................................................................................................................................214 bcsqrt....................................................................................................................................214 bcsub.....................................................................................................................................214 V.FuncionesdecompresiónBzip2...............................................................................................216 bzclose..................................................................................................................................218 bzcompress...........................................................................................................................218 bzdecompress.......................................................................................................................218 bzerrno..................................................................................................................................219 bzerror...................................................................................................................................219 bzerrstr..................................................................................................................................220 bzflush...................................................................................................................................220 ix bzopen...................................................................................................................................220 bzread...................................................................................................................................221 bzwrite..................................................................................................................................221 VI.Funcionesdecalendario...........................................................................................................223 cal_days_in_month...............................................................................................................225 cal_from_jd...........................................................................................................................225 cal_info.................................................................................................................................225 cal_to_jd...............................................................................................................................225 easter_date............................................................................................................................225 easter_days...........................................................................................................................226 FrenchToJD..........................................................................................................................227 GregorianToJD.....................................................................................................................227 JDDayOfWeek......................................................................................................................228 JDMonthName.....................................................................................................................228 JDToFrench..........................................................................................................................229 JDToGregorian.....................................................................................................................229 JDToJewish...........................................................................................................................229 JDToJulian............................................................................................................................229 jdtounix.................................................................................................................................229 JewishToJD...........................................................................................................................230 JulianToJD............................................................................................................................230 unixtojd.................................................................................................................................230 VII.FuncionesdelAPIdeCCVS..................................................................................................232 ccvs_add...............................................................................................................................233 ccvs_auth..............................................................................................................................233 ccvs_command.....................................................................................................................233 ccvs_count............................................................................................................................233 ccvs_delete...........................................................................................................................234 ccvs_done.............................................................................................................................234 ccvs_init................................................................................................................................234 ccvs_lookup..........................................................................................................................235 ccvs_new..............................................................................................................................235 ccvs_report...........................................................................................................................235 ccvs_return...........................................................................................................................236 ccvs_reverse..........................................................................................................................236 ccvs_sale...............................................................................................................................236 ccvs_status............................................................................................................................237 ccvs_textvalue......................................................................................................................237 ccvs_void..............................................................................................................................237 VIII.soportedelasfuncionesCOMparaWindows......................................................................239 COM.....................................................................................................................................240 VARIANT.............................................................................................................................241 com_addref...........................................................................................................................242 com_get................................................................................................................................242 com_invoke...........................................................................................................................243 com_isenum..........................................................................................................................243 com_load_typelib.................................................................................................................243 com_load..............................................................................................................................243 x

Description:
Manual de PHP. Stig Sæther Bakken. Alexander Aulbach. Egon Schmid. Jim Winstead. Lars Torben Wilson. Rasmus Lerdorf. Andrei Zmievski.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.