cvs: phpdoc /cs translation.xml /cs/faq installation.xml using.xml /cs/language references.xml
| From: | Lukas Jelinek | Date: | Thu, 14 Mar 2002 23:17:34 +0000 |
| Subject: | cvs: phpdoc /cs translation.xml /cs/faq installation.xml using.xml /cs/language references.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969343066@lists.php.net to get a copy of this message | ||
luk Thu Mar 14 18:17:34 2002 EDT
Added files:
/phpdoc/cs/faq using.xml
/phpdoc/cs/language references.xml
Modified files:
/phpdoc/cs translation.xml
/phpdoc/cs/faq installation.xml
Log:
Index: phpdoc/cs/translation.xml diff -u phpdoc/cs/translation.xml:1.2 phpdoc/cs/translation.xml:1.3 --- phpdoc/cs/translation.xml:1.2 Tue Mar 12 16:21:52 2002 +++ phpdoc/cs/translation.xml Thu Mar 14 18:17:32 2002 @@ -14,11 +14,18 @@ </translators> <work-in-progress> - <file name="appendices/phpdevel.xml" person="luk" type="translation" /> - <file name="faq/installation.xml" person="luk" type="translation" /> - <file name="faq/mailinglist.xml" person="luk" type="translation" /> - <file name="faq/using.xml" person="luk" type="translation" /> - <file name="functions/mysql.xml" person="costra" type="translation" /> + <file name="appendices/phpdevel.xml" person="luk" type="translation" /> + <file name="appendices/predefined.xml" person="luk" type="translation" /> + <file name="appendices/resources.xml" person="luk" type="translation" /> + <file name="functions/mysql.xml" person="costra" type="translation" /> + <file name="language/control-structures.xml person="luk" type="translation" /> + <file name="language/expressions.xml person="luk" type="translation" /> + <file name="language/functions.xml person="luk" type="translation" /> + <file name="language/operators.xml person="luk" type="translation" /> + <file name="language/oop.xml person="luk" type="translation" /> + <file name="language/references.xml person="luk" type="translation" /> + <file name="language/types.xml person="luk" type="translation" /> + <file name="language/variables.xml person="luk" type="translation" /> </work-in-progress> </translation> Index: phpdoc/cs/faq/installation.xml diff -u phpdoc/cs/faq/installation.xml:1.1 phpdoc/cs/faq/installation.xml:1.2 --- phpdoc/cs/faq/installation.xml:1.1 Wed Mar 13 16:43:21 2002 +++ phpdoc/cs/faq/installation.xml Thu Mar 14 18:17:33 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- EN-Revision: 1.13 Maintainer: luk Status: mixed --> +<!-- EN-Revision: 1.13 Maintainer: luk Status: ready --> <chapter id="faq.installation"> <title>Instalace</title> @@ -23,25 +23,25 @@ <qandaentry id="faq.installation.phpini"> <question> <para> - Unix/Windows: Where should my php.ini file be located? + Unix/Windows: Kde by mìl být ulo¾en soubor php.ini? </para> </question> <answer> <para> - By default on UNIX it should be in <filename>/usr/local/lib</filename>. - Most people will want to change this at compile-time with the - <link linkend="install.configure.with-config-file-path">--with-config-file-path</link> - flag. You would, for example, set it with something like: + V UNIXu má být implicitnì v adresáøi <filename>/usr/local/lib</filename>. + Mnoho lidí to bude chtít pøi kompilaci zmìnit pomocí parametru + <link linkend="install.configure.with-config-file-path">--with-config-file-path</link>. + Mohli byste ho, napøíklad, nastavit zhruba takto: <programlisting> --with-config-file-path=/etc </programlisting> - And then you would copy <filename>php.ini-dist</filename> from - the distribution to <filename>/etc/php.ini</filename> and - edit it to make any local changes you want. + Pak byste zkopírovali soubor <filename>php.ini-dist</filename> z + distribuce do <filename>/etc/php.ini</filename> a upravili tak, jak + chcete. </para> <para> - On Windows the default path for the <filename>php.ini</filename> - file is the Windows directory. + Pod Windows je soubor <filename>php.ini</filename> implicintì umístìn + v adresáøi systému Windows. </para> </answer> </qandaentry> @@ -49,23 +49,22 @@ <qandaentry id="faq.installation.nodata"> <question> <para> - Unix: I installed PHP, but every time I load a document, I get the - message 'Document Contains No Data'! What's going on here? + UNIX: Nainstaloval jsem PHP, ale v¾dy, kdy¾ naèítám dokument, dostanu + zprávu 'Document Contains No Data'! O co jde? </para> </question> <answer> <para> - This probably means that PHP is having some sort of problem - and is core-dumping. Look in your server error log to see if - this is the case, and then try to reproduce the problem with - a small test case. If you know how to use 'gdb', it is very - helpful when you can provide a backtrace with your bug report - to help the developers pinpoint the problem. If you are using - PHP as an Apache module try something like: + Pravdìpobnì to znamená, ¾e PHP má nìjaký problém a padá. Podívejte se + do protokolu chyb, zda se jedná o tento pøípad a pak zkuste problém + reprodukovat malým testem. Pokud víte, jak pou¾ívat 'gdb', velmi pomù¾e, + kdy¾ mù¾ete s va¹ím hlá¹ením chyby poskytnout výpis (backtrace). + Vývojáøi tak mohou snadnìji lokalizovat problém. Pou¾íváte-li PHP jako + modul do serveru Apache, zkuste nìco jako: <itemizedlist> <listitem> <para> - Stop your httpd processes + Zastavte httpd procesy </para> </listitem> <listitem> @@ -75,7 +74,7 @@ </listitem> <listitem> <para> - Stop your httpd processes + Zastavte httpd procesy </para> </listitem> <listitem> @@ -85,7 +84,7 @@ </listitem> <listitem> <para> - Then fetch the URL causing the problem with your browser + Potom naètìte do prohlí¾eèe URL, kde se vyskytl problém </para> </listitem> <listitem> @@ -95,28 +94,28 @@ </listitem> <listitem> <para> - If you are getting a core dump, gdb should inform you of this now + Dostanete-li core dump (PHP spadne), gdb by vás o tom mìl informovat </para> </listitem> <listitem> <para> - type: bt + napi¹te: bt </para> </listitem> <listitem> <para> - You should include your backtrace in your bug report. This should be submitted to + Získaný výpis (backtrace) byste mìli pøilo¾it k hlá¹ení chyby. + To by se mìlo poslat na <ulink url="&faqurl.php.bugs;">&faqurl.php.bugs;</ulink> </para> </listitem> </itemizedlist> </para> <para> - If your script uses the regular expression functions - (<function>ereg</function> and friends), you should make sure - that you compiled PHP and Apache with the same regular - expression package. This should happen automatically with - PHP and Apache 1.3.x + Pokud vá¹ skript pou¾ívá funkce pro regulární výrazy + (<function>ereg</function> a dal¹í), mìli byste se ujistit, ¾e jste + zkompilovali PHP a Apache se stejným balíèkem pro regulární výrazy. + S PHP a Apachem 1.3.x by se to mìlo dít automaticky. </para> </answer> </qandaentry> @@ -124,15 +123,16 @@ <qandaentry id="faq.installation.processing"> <question> <para> - Unix: I installed PHP using RPMS, but Apache isn't processing the - PHP pages! What's going on here? + UNIX: Instaloval jsem PHP z balíèkù RPM, ale Apache nezpracovává stránky + s PHP! O co tu jde? </para> </question> <answer> <para> - Assuming you installed both Apache and PHP from RPM packages, - you need to uncomment or add some or all of the following lines - in your <filename>http.conf</filename> file: + Za pøedpokladu, ¾e se obojí, jak Apache, tak PHP, instalovalo z + balíèkù RPM, bude tøeba "odkomentovat" nebo pøidat do souboru + <filename>http.conf</filename> nìkteré z následujících øádkù (nebo + v¹echny): <programlisting> # Extra Modules AddModule mod_php.c @@ -141,17 +141,17 @@ # Extra Modules LoadModule php_module modules/mod_php.so -LoadModule php3_module modules/libphp3.so /* for PHP 3 */ -LoadModule php4_module modules/libphp4.so /* for PHP 4 */ +LoadModule php3_module modules/libphp3.so /* pro PHP 3 */ +LoadModule php4_module modules/libphp4.so /* pro PHP 4 */ LoadModule perl_module modules/libperl.so </programlisting> - And add: + Pøidejte také: <programlisting> -AddType application/x-httpd-php3 .php3 /* for PHP 3 */ -AddType application/x-httpd-php .php /* for PHP 4 */ +AddType application/x-httpd-php3 .php3 /* pro PHP 3 */ +AddType application/x-httpd-php .php /* pro PHP 4 */ </programlisting> - ... to the global properties, or to the properties of the - VirtualDomain you want to have PHP support added to. + ... do globálních vlastností nebo do vlastností virtuální domény + (VirtualDomain) by se mìla pøidat podpora PHP. </para> </answer> </qandaentry> @@ -159,37 +159,37 @@ <qandaentry id="faq.installation.compile"> <question> <para> - Unix: I installed PHP 3 using RPMS, but it doesn't compile with - the database support I need! What's going on here? + UNIX: Instaloval jsem PHP 3 z balíèkù RPM, ale nekompiluje se s podporou + databáze, kterou potøebuji! O co tu jde? </para> </question> <answer> <para> - Due to the way PHP 3 built, it is not easy to build a - complete flexible PHP RPM. This issue is addressed in PHP 4. - For PHP 3, we currently suggest you use the mechanism described in the - INSTALL.REDHAT file in the PHP distribution. If you insist on using - an RPM version of PHP 3, read on... + Kvùli tomu, jak se PHP 3 budovalo, není snadné sestavit kompletní + flexibilní RPM balíèek s PHP. Problém je vyøe¹en v PHP 4. Pro PHP 3 + nyní doporuèujeme pou¾ívat mechanismus popsaný v souboru + INSTALL.REDHAT v distribuci PHP. Pokud trváte na pou¾ití RPM verze PHP 3, + ètìte dál... </para> <para> - The RPM packagers are setting up the RPMS to install - without database support to simplify installations <emphasis>and</emphasis> - because RPMS use /usr/ instead of the standard /usr/local/ directory for - files. You need to tell the RPM spec file which databases to support - and the location of the top-level of your database server. + RPM pakovaèe jsou nastaveny na tvorbu RPM balíèkù k instalaci bez + podpory databází kvùli zjednodu¹ení instalací <emphasis>a</emphasis> + proto, ¾e RPM pou¾ívá adresáø /usr/ namísto standardního /usr/local/. + Musít sdìlit RPM souboru spec, které databáze podporovat a umístìní + adresáøe nejvy¹¹í úrovnì databázového serveru. </para> <para> - This example will explain the process of adding support for the - popular MySQL database server, using the mod installation for Apache. + Tento pøíklad vysvìtluje proces pøidání podpory populárního databázového + serveru MySQL, pro instalaci PHP jako modulu do Apache. </para> <para> - Of course all of this information can be adjusted for any database - server that PHP supports. We will assume you installed MySQL and Apache - completely with RPMS for this example as well. + V¹echny tyto informace smaozøejmì mohou být upraveny pro libovolný + databázový server, který PHP podporuje. Pro tento pøíklad budeme + pøedpokládat, ¾e jste instalovali MySQL a Apache plnì z balíèkù RPM. <itemizedlist> <listitem> <para> - First remove mod_php3 : + Nejdøíve odstraòte mod_php3 : <programlisting> rpm -e mod_php3 </programlisting> @@ -197,7 +197,7 @@ </listitem> <listitem> <para> - Then get the source rpm and INSTALL it, NOT --rebuild + Potom vezmìte zdrojový balíèek RPM a spus»te na nìm, NE --rebuild <programlisting> rpm -Uvh mod_php3-3.0.5-2.src.rpm </programlisting> @@ -205,17 +205,19 @@ </listitem> <listitem> <para> - Then edit the <filename>/usr/src/redhat/SPECS/mod_php3.spec</filename> file + Upravte soubor + <filename>/usr/src/redhat/SPECS/mod_php3.spec</filename> </para> <para> - In the %build section add the database support you want, and the path. + V sekci %build pøidejte databázovou podporu, kterou chcete, a nastavte + cestu. </para> <para> - For MySQL you would add + Pro MySQL byste pøidali <programlisting> --with-mysql=/usr \ </programlisting> - The %build section will look something like this: + Sekce %build bude vypadat pøibli¾nì takto: <programlisting> ./configure --prefix=/usr \ --with-apxs=/usr/sbin/apxs \ @@ -230,7 +232,7 @@ </listitem> <listitem> <para> - Once this modification is made then build the binary rpm as follows: + Poté, co jsou provedeny tyto zmìny, zkompilujte balíèek takto: <programlisting> rpm -bb /usr/src/redhat/SPECS/mod_php3.spec </programlisting> @@ -238,17 +240,17 @@ </listitem> <listitem> <para> - Then install the rpm + Potom balíèek nainstalujte: <programlisting> rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm </programlisting> </para> </listitem> </itemizedlist> - Make sure you restart Apache, and you now have PHP 3 with MySQL support - using RPM's. Note that it is probably much easier to just build - from the distribution tarball of PHP 3 and follow the instructions in - <filename>INSTALL.REDHAT</filename> found in that distribution. + Ujistìte se, ¾e jste restartovali Apache, a nyní ji¾ máte PHP 3 s + podporou MySQL. Uvìdomte si, ¾e je pravdìpodobnì mnohem jednodu¹¹í + zkompilovat distribuèní balíèek tar a dr¾et se instrukcí v souboru + <filename>INSTALL.REDHAT</filename> z distribuce. </para> </answer> </qandaentry> @@ -256,17 +258,17 @@ <qandaentry id="faq.installation.frontpage"> <question> <para> - Unix: I patched Apache with the FrontPage extensions patch, and - suddenly PHP stopped working. Is PHP incompatible with the - Apache FrontPage extensions? + UNIX: Pøidal jsem do Apache patch pro FrontPage Extension a PHP náhle + pøestalo pracovat. Je PHP nekompatibilní s FrontPage Extension pro + Apache? </para> </question> <answer> <para> - No, PHP works fine with the FrontPage extensions. The problem - is that the FrontPage patch modifies several Apache structures, - that PHP relies on. Recompiling PHP (using 'make clean ; make') - after the FP patch is applied would solve the problem. + Ne, PHP pracuje dobøe i s FrontPage Extension. Problém je v tom, ¾e + FrontPage patch modifikuje nìkteré struktury Apache, na které PHP + spoléhá. Pøekompilování PHP (pou¾itím 'make clean ; make') po instalaci + FP patche by mìlo problém vyøe¹it. </para> </answer> </qandaentry> @@ -274,18 +276,16 @@ <qandaentry id="faq.installation.blankscreen"> <question> <para> - Unix/Windows: I have installed PHP, but when I try to - access a PHP script file via my browser, I get a blank screen. + UNIX/Windows: Nainstaloval jsem PHP, ale pøi pokusu naèíst soubor PHP + skriptu do prohlí¾eèe se zobrazí pouze prázdná obrazovka. </para> </question> <answer> <para> - Do a 'view source' in the web browser and you will probably - find that you can see the source code of your PHP script. - This means that the web server did not send the script to - PHP for interpretation. Something is wrong with the server - configuration - double check the server configuration against - the PHP installation instructions. + V prohlí¾eèi vyberte funkci 'zobrazit zdrojový kód', nejspí¹ uvidíte + zdrojový kód va¹eho PHP skriptu. To znamená, ¾e server neposílá skript + k interpretaci. Chyba je nìkde v konfiguraci serveru - radìji dvakrát + zkontrolujte konfiguraci podle instrukcí k instalaci PHP. </para> </answer> </qandaentry> @@ -293,24 +293,20 @@ <qandaentry id="faq.installation.500error"> <question> <para> - Unix/Windows: I have installed PHP, but when try to - access a PHP script file via my browser, I get a - server 500 error. + UNIX/Windows: Nainstaloval jsem PHP a kdy¾ chci naèíst PHP soubor do + prohlí¾eèe, objeví se "500 Internal Server Error". </para> </question> <answer> <para> - Something went wrong when the server tried to run PHP. To - get to see a sensible error message, from the command line, - change to the directory containing the PHP executable - (<filename>php.exe</filename> on Windows) and run - <literal>php -i</literal>. If PHP has any problems running, - then a suitable error message will be displayed which will - give you a clue as to what needs to be done next. If you - get a screen full of html codes (the output of the - <function>phpinfo</function> function) then PHP is working, - and your problem may be related to your server configuration - which you should double check. + Pøi pokusu spustit PHP do¹lo k nìjaké chybì. Abyste vidìli detailnìj¹í + chybovou zprávu, z pøíkazové øádky, pøejdìte do adresáøe se souborem + PHP (pod Windows <filename>php.exe</filename>) a spus»te + <literal>php -i</literal>. Pokud pøi bìhu PHP dojde k chybì, bude + zobrazena odpovídající chybovou zpráva, která vám øekne, co se má dál + udìlat. Pokud získáte obrazovku plnou HTML kódu (výstup funkce + <function>phpinfo</function>), pak PHP funguje a vá¹ problém mù¾e + souviset s konfigurací serveru, kterou je pak tøeba dobøe zkontrolovat. </para> </answer> </qandaentry> @@ -318,8 +314,8 @@ <qandaentry id="faq.installation.undefinedsyms"> <question> <para> - Some operating systems: I have installed PHP without errors, - but when I try to start apache I get undefined symbol errors: + Nìkteré operaèní systémy: Nainstaloval jsem PHP bez chyb, ale nyní, + kdy¾ zkusím spustit Apache, ohlásí se chyby o nedefinovaných symbolech: <programlisting> [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: @@ -330,9 +326,9 @@ </question> <answer> <para> - This has actually nothing to do with PHP, but with the MySQL - client libraries. Some need --with-zlib, others do not. This - is also covered in the MySQL FAQ. + To aktuálnì nemá nic spoleèného s PHP, ale s knihovnami klienta MySQL. + Nìkteré potøebují --with-zlib, jiné nikoli. Tímto se zabývá také + MySQL FAQ. </para> </answer> </qandaentry> @@ -340,8 +336,8 @@ <qandaentry id="faq.installation.cgierror"> <question> <para> - Windows: I have installed PHP, but when I to access - a PHP script file via my browser, I get the error: + Windows: Nainstaloval jsem PHP, ale pøi naètení stránky do prohlí¾eèe + se zobrazí chyba: <programlisting> cgi error: The specified CGI application misbehaved by not @@ -352,42 +348,38 @@ </question> <answer> <para> - This error message means that PHP failed to output anything - at all. To get to see a sensible error message, from the - command line, change to the directory containing the PHP - executable (<filename>php.exe</filename> on Windows) and run - <literal>php -i</literal>. If PHP has any problems running, - then a suitable error message will be displayed which will - give you a clue as to what needs to be done next. If you - get a screen full of html codes (the output of the - <function>phpinfo</function> function) then PHP is working. + Tato chybová zpráva znamená, ¾e z PHP nemohou vycházet ¾ádná data. + Abyste vidìli detailnìj¹í + chybovou zprávu, z pøíkazové øádky, pøejdìte do adresáøe se souborem + PHP (pod Windows <filename>php.exe</filename>) a spus»te + <literal>php -i</literal>. Pokud pøi bìhu PHP dojde k chybì, bude + zobrazena odpovídající chybovou zpráva, která vám øekne, co se má dál + udìlat. Pokud získáte obrazovku plnou HTML kódu (výstup funkce + <function>phpinfo</function>), PHP funguje. </para> <para> - Once PHP is working at the command line, try accessing the - script via the browser again. If it still fails then it - could be one of the following: + Jestli¾e PHP pracuje v pøíkazové øádce, zkuste to znovu z prohlí¾eèe. + Pokud to stále nefunguje, mù¾e to být jedním z tìchto dùvodù: </para> <itemizedlist> <listitem> <simpara> - File permissions on your PHP script, + Nastavení pøístupových práv k souboru se skriptem, k <filename>php.exe</filename>, <filename>php4ts.dll</filename>, - <filename>php.ini</filename> or any PHP extensions you are - trying to load are such that the anonymous internet user - <literal>ISUR_<machinename></literal> cannot access them. + <filename>php.ini</filename> nebo nìjakému roz¹íøení PHP, které se + pokou¹íte naèíst, je takové, ¾e k nim anonymní internetový u¾ivatel + <literal>ISUR_<machinename></literal> nemá pøístup. </simpara> </listitem> <listitem> <simpara> - The script file does not exist (or possibly isn't where you - think it is relative to your web root directory). Note that - for IIS you can trap this error by ticking the 'check file - exists' box when setting up the script mappings in the - Internet Services Manager. If a script file does not exist - then the server will return a 404 error instead. There is - also the additional benefit that IIS will do any - authentication required for you based on the NTLanMan - permissions on your script file. + Soubor se skriptem neexistuje (nebo pøípadnì není tam, kde si myslíte, + ¾e je, relativnì ke koøenovému adresáøi webu). Uvìdomte si, ¾e + na IIS mù¾ete tuto chybu zachytit za¹krtnutím volby 'check file + exists' pøi nastavování skriptových slu¾eb v Internet Services + Manageru. Pokud skript neexistuje, server vrátí chybu 404. Dal¹í + výhodou je to, ¾e IIS provede na souboru se skriptem v¹echny potøebné + autentikace zalo¾ené NTLanMan. </simpara> </listitem> </itemizedlist> @@ -397,18 +389,18 @@ <qandaentry id="faq.install.phpandiis"> <question> <para> - Windows: I've followed all the instructions, but still can't - get PHP and IIS to work together! + Windows: Dodr¾el jsem v¹echny instrukce, ale PHP a IIS stále odmítají + spolupracovat! </para> </question> <answer> <para> - Make sure any user who needs to run a PHP script has the rights - to run <filename>php.exe</filename>! IIS uses an anonymous user - which is added at the time IIS is installed. This user needs - rights to <filename>php.exe</filename>. Also, any authenticated - user will also need rights to execute <filename>php.exe</filename>. - And for IIS4 you need to tell it that PHP is a script engine. + Ujistìte se, ¾e ka¾dý u¾ivatel, který potøebuje spou¹tìt PHP skripty má + práva pro spou¹tìní <filename>php.exe</filename>! IIS pou¾ívá anonymního + u¾ivatele, který se pøidá pøi instalaci IIS. Tento u¾ivatel potøebuje + práva k <filename>php.exe</filename>. Také ka¾dý autentikovaný u¾ivatel + bude potøebovat práva na spou¹tìní <filename>php.exe</filename>. + A IIS4 musíte sdìlit, ¾e PHP je skriptovací engine. </para> </answer> </qandaentry> Index: phpdoc/cs/faq/using.xml +++ phpdoc/cs/faq/using.xml <?xml version="1.0" encoding="iso-8859-2"?> <!-- EN-Revision: 1.14 Maintainer: luk Status: ready --> <chapter id="faq.using"> <title>Pou¾ívání PHP</title> <titleabbrev>Pou¾ívání PHP</titleabbrev> <para> Tato èást shrnuje nejèastìj¹í chyby, se kterými se mù¾ete setkat pøi psaní PHP skriptù. </para> <qandaset> <qandaentry id="faq.using.anyform"> <question> <para> Chtìl bych napsat generický PHP skript, který by umìl zpracovat data z jakéhokoli formuláøe. Jak se dozvím, které promìnné metody POST jsou k dispozici? </para> </question> <answer> <para> Ujistìte se, ¾e máte v souboru <filename>php.ini</filename> zapnuto <link linkend="ini.track-vars">track_vars</link> Od PHP 4.0.3 je tato mo¾nost v¾dy zapnuta. Pokud tomu tak je, vytvoøí se nìjaká asociativní pole, z nich¾ nejdùle¾itìj¹í je <literal>$HTTP_POST_VARS</literal>. Tak¾e pro psaní generického skriptu pro obsluhu promìnných metody POST budete potøebovat pøibli¾nì toto: <programlisting role="php"> <![CDATA[ foreach ($HTTP_POST_VARS as $var => $value) { echo "$var = $value<br>\n"; } ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.using.singlequotes"> <question> <para> Potøebuji pøevést v¹echny apostrofy (') na zpìtná lomítka následovaná apostrofy. Jak se to dá udìlat pomocí regulárního výrazu? </para> </question> <answer> <para> Nejdøíve se podívejte na funkci <function>addslashes</function>. Dìlá pøesnì to, co potøebujete. Mìli byste se také podívat na direktivu <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> v souboru <filename>php.ini</filename>. </para> </answer> </qandaentry> <qandaentry id="faq.using.wrong-order"> <question> <para> Kdy¾ napí¹u následující kód, výstup se tiskne v nesprávném poøadí: <programlisting role="php"> function myfunc($argument) { echo $argument + 10; } $variable = 10; echo "myfunc($variable) = " . myfunc($variable); </programlisting> what's going on? </para> </question> <answer> <para> Pro pou¾ití výsledkù va¹í funkce ve výrazu (jako je spojení s jiným øetìzcem v pøíkladu vý¹e), musíte hodnotu <emphasis>vracet</emphasis> (pomocí <emphasis>vracet</emphasis>), ne <function>tisknout</function> (pomocí <function>echo</function>). </para> </answer> </qandaentry> <qandaentry id="faq.using.newlines"> <question> <para> Hej, co se stalo s mými konci øádkù? <programlisting role="php"> <![CDATA[ <pre> <?php echo "Tohle by mìl být první øádek."; ?> <?php echo "Tohle by se mìlo ukázat na novém øádku."; ?> </pre> ]]> </programlisting> </para> </question> <answer> <para> V PHP se blok kódu zakonèuje buï "?>", nebo "?>\n" (kde \n znamená nový øádek). Tak¾e ve vý¹e uvedeném pøíkladu budou vypsané vìty na jediném øádku, proto¾e PHP vynechává konce øádkù za koncem bloku. To znamená, ¾e musíte pøidávat zvlá¹tní konce øádkù za ka¾dý blok PHP kódu, aby se vytisklo odøádkování jediné. </para> <para> Proè to PHP dìlá? Pøi formátování normálního HTML to obvykle zjednodu¹uje ¾ivot, proto¾e nechcete konce øádkù, nýbr¾ chcete vytvoøit extrémnì dlouhé øádky nebo jinak zneèitelnit zdrojový kód. </para> </answer> </qandaentry> <qandaentry id="faq.using.headers-sent"> <question> <para> Zobrazila se mi zpráva 'Warning: Cannot send session cookie - headers already sent...' nebo 'Cannot add header information - headers already sent...'. </para> </question> <answer> <para> Funkce <function>header</function>, <function>set_cookie</function> a funkce session musí do výstupu pøidat hlavièky. Hlavièky je mo¾no posílat pouze pøed vlastním obsahem. Funkce to udìlají, pokud PHP bì¾í jako modul Apache. Následující kus kódu zobrazí v¹echny hlavièky v po¾adavku: <programlisting role="php"> <![CDATA[ $headers = getallheaders(); foreach ($headers as $name => $content) { echo "headers[$name] = $content<br>\n"; } ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.using.header"> <question> <para> Potøebuji pøímo pøistupovat k hlavièce po¾adavku. Jak to udìlat? </para> </question> <answer> <para> Funkce <function>getallheaders</function> to udìlá, pokud PHP bì¾í jako modul do Apache. Následující kus kódu zobrazí v¹echny hlavièky v po¾adavku: <programlisting role="php"> <![CDATA[ $headers = getallheaders(); foreach ($headers as $name => $content) { echo "headers[$name] = $content<br>\n"; } ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.using.authentication"> <question> <para> Kdy¾ zkusím autentikaci s IIS, dostanu 'No Input file specified'. </para> </question> <answer> <para> Bezpeènostní model IIS je s tím na ¹tíru. Je to problém spoleèný v¹em CGI programùm bì¾ícím pod IIS. Øe¹ením je vytvoøit obyèejný HTML soubor (neparsovaný PHP) jako vstupní stránku do autentikovaného adresáøe. Potom se pou¾ije META tag k pøesmìrování na PHP stránku nebo odkaz k ruènímu pøechodu. PHP pak autentikaci zpracuje správnì. S modulem ISAPI toto není problémem. Jiných NT webovských serverù se problém netýká. Více informací - viz <ulink url="&faqurl.iis;">&faqurl.iis;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.using.netscape"> <question> <para> Mùj PHP skript pracuje na IE a Lynxu, ale v Netscapu èást výstupu mizí. Kdy¾ si zapnu "Zobrazit zdrojový kód", v IE vidím obsah, v Netscapu nikoliv. </para> </question> <answer> <para> Netscape je striktnìj¹í ohlednì HTML tagù (napø. tabulek) nì¾ IE. Kontrola HTML výstupu pomocí HTML validátoru, jako je <ulink url="&faqurl.w3.validator;">validator.w3.org</ulink>, mù¾e být nápomocna. Napøíklad chybìjící </table> zpùsobuje vý¹e uvedený problém. </para> <para> IE i Lynx také ignorují jakékoliv nulové (<literal>\0</literal>) znaky v HTML proudu, Netscape nikoli. Nejlep¹í cestou k ovìøení je zkompilovat verzi PHP pro <link linkend="commandline">pøíkazovou øádku</link> (známou jako CGI verze) a spustit skript z pøíkazové øádky. Na *NIXech to pøesmìrujte do <literal>od -c</literal> a hledejte znaky <literal>\0</literal>. Pod Windows musíte najít editor nebo jiný program, který umo¾òuje prohlí¾ení binárních souborù. Kdy¾ Netscape uvidí v souboru nulový znak, typicky nic dal¹ího nezobrazí, aèkoli IE i Lynx ano. </para> </answer> </qandaentry> <qandaentry id="faq.using.mixml"> <question> <para> Jaké jsou pøedpoklady míchání XML a PHP? Stì¾uje si to na moje <?xml> tagy! </para> </question> <answer> <para> Musíte vypnout krátké tagy v souboru <filename>php.ini</filename> nastavením <link linkend="ini.short-open-tag">short_tags</link> na 0 nebo pou¾itím odpovídající direktivy Apache. Mù¾ete také pou¾ít sekci <File> k selektivnímu nastavení. </para> </answer> </qandaentry> <qandaentry id="faq.using.editor"> <question> <para> Jak mohu pou¾ít PHP s FrontPagem nebo jiným HTML editorem, který trvá na odsunutí mého kódu? </para> </question> <answer> <para> Jedním z nejjednodu¹¹ích zpùsobù je povolit pou¾ití ASP tagù v PHP kódu. To umo¾ní pou¾ívat oddìlovaèe v ASP stylu (<% a %>). Nìkteré populární HTML editory s pracují (v tuto chvíli) inteligentnìji. K zapnutí ASP tagù musíte v souboru <filename>php.ini</filename> nastavit promìnnou <link linkend="ini.asp-tags">asp_tags</link> nebo pou¾ít pøíslu¹nou direktivu Apache. </para> </answer> </qandaentry> <qandaentry id="faq.using.variables"> <question> <para> Kde najdi úplný seznam dostupných pøednastavených promìnných, a proè to není zdokumentováno v dokumentaci PHP? </para> </question> <answer> <para> Nejlep¹í metodou je vlo¾it do stránky <literal><?php phpinfo(); ?></literal> a naèíst to do prohlí¾eèe. Zobrazí se informace v¹eho druhu o nainstalovaném PHP, vèetnì seznamu promìnných prostøedí i speciálních promìnných nastavovaných HTTP serverem. Tento seznam opravdu nemù¾e být zdokumentován v dokumentaci k PHP, prot¾e se li¹í server od serveru. </para> </answer> </qandaentry> <qandaentry id="faq.using.cgi-vars"> <question> <para> Zkou¹ím pøistupovat k jedné ze standardních CGI promìnných (jako je $DOCUMENT_ROOT nebo $HTTP_REFERER) v u¾ivatelsky definované funkci, a nemù¾e ji to najít. Co je ¹patnì? </para> </question> <answer> <para> Promìnné prostøedí jsou normální globální promìnné, tak¾e je musíte buï deklarovat ve funkci jako globální promìnné (napøíklad pou¾itím "<literal>global $DOCUMENT_ROOT;</literal>") nebo pou¾ít pole globálních promìnných (napø. "<literal>$GLOBALS["DOCUMENT_ROOT"]</literal>"). </para> </answer> </qandaentry> </qandaset> </chapter> <!-- 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:"../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: --> Index: phpdoc/cs/language/references.xml +++ phpdoc/cs/language/references.xml <?xml version="1.0" encoding="iso-8859-2"?> <!-- EN-Revision: 1.22 Maintainer: luk Status: mixed --> <chapter id="language.references"> <title>Vysvìtlení referencí (odkazù)</title> <sect1 id="language.references.whatare"> <title>Co jsou reference</title> <simpara> References are a means in PHP to access the same variable content by different names. They are not like C pointers, they are symbol table aliases. Note that in PHP, variable name and variable content are different, so the same content can have different names. The most close analogy is with Unix filenames and files - variable names are directory entries, while variable contents is the file itself. References can be thought of as hardlinking in Unix filesystem. </simpara> </sect1> <sect1 id="language.references.whatdo"> <title>What References Do</title> <para> PHP references allow you to make two variables to refer to the same content. Meaning, when you do: <informalexample> <programlisting role="php"> <![CDATA[ $a =& $b ]]> </programlisting> </informalexample> it means that <varname>$a</varname> and <varname>$b</varname> point to the same variable. <note> <para> <varname>$a</varname> and <varname>$b</varname> are completely equal here, that's not <varname>$a</varname> is pointing to <varname>$b</varname> or vice versa, that's <varname>$a</varname> and <varname>$b</varname> pointing to the same place. </para> </note> </para> <para> The same syntax can be used with functions, that return references, and with <literal>new</literal> operator (in PHP 4.0.4 and later): <informalexample> <programlisting role="php"> <![CDATA[ $bar =& new fooclass(); $foo =& find_var ($bar); ]]> </programlisting> </informalexample> </para> <note> <para> Not using the <literal>&</literal> operator causes a copy of the object to be made. If you use <literal>$this</literal> in the class it will operate on the current instance of the class. The assignment without <literal>&</literal> will copy the instance (i.e. the object) and <literal>$this</literal> will operate on the copy, which is not always what is desired. Usually you want to have a single instance to work with, due to performance and memory consumption issues. </para> </note> <para> The second thing references do is to pass variables by-reference. This is done by making a local variable in a function and a variable in the calling scope reference to the same content. Example: <informalexample> <programlisting role="php"> <![CDATA[ function foo (&$var) { $var++; } $a=5; foo ($a); ]]> </programlisting> </informalexample> will make <varname>$a</varname> to be 6. This happens because in the function <varname>foo</varname> the variable <varname>$var</varname> refers to the same content as <varname>$a</varname>. See also more detailed explanations about <link linkend="language.references.pass">passing by reference</link>. </para> <simpara> The third thing reference can do is <link linkend="language.references.return">return by reference</link>. </simpara> </sect1> <sect1 id="language.references.arent"> <title>What References Are Not</title> <para> As said before, references aren't pointers. That means, the following construct won't do what you expect: <informalexample> <programlisting role="php"> <![CDATA[ function foo (&$var) { $var =& $GLOBALS["baz"]; } foo($bar); ]]> </programlisting> </informalexample> </para> <simpara> What happens is that <varname>$var</varname> in <varname>foo</varname> will be bound with <varname>$bar</varname> in caller, but then it will be re-bound with <varname>$GLOBALS["baz"]</varname>. There's no way to bind <varname>$bar</varname> in the calling scope to something else using the reference mechanism, since <varname>$bar</varname> is not available in the function <varname>foo</varname> (it is represented by <varname>$var</varname>, but <varname>$var</varname> has only variable contents and not name-to-value binding in the calling symbol table). </simpara> </sect1> <sect1 id="language.references.pass"> <title>Passing by Reference</title> <para> You can pass variable to function by reference, so that function could modify its arguments. The syntax is as follows: <informalexample> <programlisting role="php"> <![CDATA[ function foo (&$var) { $var++; } $a=5; foo ($a); // $a is 6 here ]]> </programlisting> </informalexample> Note that there's no reference sign on function call - only on function definition. Function definition alone is enough to correctly pass the argument by reference. </para> <para> Following things can be passed by reference: <itemizedlist> <listitem> <simpara> Variable, i.e. <literal>foo($a)</literal> </simpara> </listitem> <listitem> <simpara> New statement, i.e. <literal>foo(new foobar())</literal> </simpara> </listitem> <listitem> <para> Reference, returned from a function, i.e.: <informalexample> <programlisting role="php"> <![CDATA[ function &bar() { $a = 5; return $a; } foo(bar()); ]]> </programlisting> </informalexample> See also explanations about <link linkend="language.references.return">returning by reference</link>. </para> </listitem> </itemizedlist> </para> <para> Any other expression should not be passed by reference, as the result is undefined. For example, the following examples of passing by reference are invalid: <informalexample> <programlisting role="php"> <![CDATA[ function bar() // Note the missing & { $a = 5; return $a; } foo(bar()); foo($a = 5) // Expression, not variable foo(5) // Constant, not variable ]]> </programlisting> </informalexample> These requirements are for PHP 4.0.4 and later. </para> </sect1> <sect1 id="language.references.return"> <title>Returning References</title> <para> Returning by-reference is useful when you want to use a function to find which variable a reference should be bound to. When returning references, use this syntax: <informalexample> <programlisting role="php"> <![CDATA[ function &find_var ($param) { ...code... return $found_var; } $foo =& find_var ($bar); $foo->x = 2; ]]> </programlisting> </informalexample> In this example, the property of the object returned by the <varname>find_var</varname> function would be set, not the copy, as it would be without using reference syntax. </para> <note> <simpara> Unlike parameter passing, here you have to use <literal>&</literal> in both places - to indicate that you return by-reference, not a copy as usual, and to indicate that reference binding, rather than usual assignment, should be done for <varname>$foo</varname>. </simpara> </note> </sect1> <sect1 id="language.references.unset"> <title>Unsetting References</title> <para> When you unset the reference, you just break the binding between variable name and variable content. This does not mean that variable content will be destroyed. For example: <informalexample> <programlisting role="php"> <![CDATA[ $a = 1; $b =& $a; unset ($a); ]]> </programlisting> </informalexample> won't unset <varname>$b</varname>, just <varname>$a</varname>. </para> <simpara> Again, it might be useful to think about this as analogous to Unix <command>unlink</command> call. </simpara> </sect1> <sect1 id="language.references.spot"> <title>Spotting References</title> <simpara> Many syntax constructs in PHP are implemented via referencing mechanisms, so everything told above about reference binding also apply to these constructs. Some constructs, like passing and returning by-reference, are mentioned above. Other constructs that use references are: </simpara> <sect2 id="references.global"> <title><literal>global</literal> References</title> <para> When you declare variable as <command>global $var</command> you are in fact creating reference to a global variable. That means, this is the same as: <informalexample> <programlisting role="php"> <![CDATA[ $var =& $GLOBALS["var"]; ]]> </programlisting> </informalexample> </para> <simpara> That means, for example, that unsetting <varname>$var</varname> won't unset global variable. </simpara> </sect2> <sect2 id="references.this"> <title><literal>$this</literal></title> <simpara> In an object method, <varname>$this</varname> is always reference to the caller object. </simpara> </sect2> </sect1> </chapter> <!-- 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:"../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: -->
Index: phpdoc/cs/translation.xml diff -u phpdoc/cs/translation.xml:1.2 phpdoc/cs/translation.xml:1.3 --- phpdoc/cs/translation.xml:1.2 Tue Mar 12 16:21:52 2002 +++ phpdoc/cs/translation.xml Thu Mar 14 18:17:32 2002 @@ -14,11 +14,18 @@ </translators> <work-in-progress> - <file name="appendices/phpdevel.xml" person="luk" type="translation" /> - <file name="faq/installation.xml" person="luk" type="translation" /> - <file name="faq/mailinglist.xml" person="luk" type="translation" /> - <file name="faq/using.xml" person="luk" type="translation" /> - <file name="functions/mysql.xml" person="costra" type="translation" /> + <file name="appendices/phpdevel.xml" person="luk" type="translation" /> + <file name="appendices/predefined.xml" person="luk" type="translation" /> + <file name="appendices/resources.xml" person="luk" type="translation" /> + <file name="functions/mysql.xml" person="costra" type="translation" /> + <file name="language/control-structures.xml person="luk" type="translation" /> + <file name="language/expressions.xml person="luk" type="translation" /> + <file name="language/functions.xml person="luk" type="translation" /> + <file name="language/operators.xml person="luk" type="translation" /> + <file name="language/oop.xml person="luk" type="translation" /> + <file name="language/references.xml person="luk" type="translation" /> + <file name="language/types.xml person="luk" type="translation" /> + <file name="language/variables.xml person="luk" type="translation" /> </work-in-progress> </translation> Index: phpdoc/cs/faq/installation.xml diff -u phpdoc/cs/faq/installation.xml:1.1 phpdoc/cs/faq/installation.xml:1.2 --- phpdoc/cs/faq/installation.xml:1.1 Wed Mar 13 16:43:21 2002 +++ phpdoc/cs/faq/installation.xml Thu Mar 14 18:17:33 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- EN-Revision: 1.13 Maintainer: luk Status: mixed --> +<!-- EN-Revision: 1.13 Maintainer: luk Status: ready --> <chapter id="faq.installation"> <title>Instalace</title> @@ -23,25 +23,25 @@ <qandaentry id="faq.installation.phpini"> <question> <para> - Unix/Windows: Where should my php.ini file be located? + Unix/Windows: Kde by mìl být ulo¾en soubor php.ini? </para> </question> <answer> <para> - By default on UNIX it should be in <filename>/usr/local/lib</filename>. - Most people will want to change this at compile-time with the - <link linkend="install.configure.with-config-file-path">--with-config-file-path</link> - flag. You would, for example, set it with something like: + V UNIXu má být implicitnì v adresáøi <filename>/usr/local/lib</filename>. + Mnoho lidí to bude chtít pøi kompilaci zmìnit pomocí parametru + <link linkend="install.configure.with-config-file-path">--with-config-file-path</link>. + Mohli byste ho, napøíklad, nastavit zhruba takto: <programlisting> --with-config-file-path=/etc </programlisting> - And then you would copy <filename>php.ini-dist</filename> from - the distribution to <filename>/etc/php.ini</filename> and - edit it to make any local changes you want. + Pak byste zkopírovali soubor <filename>php.ini-dist</filename> z + distribuce do <filename>/etc/php.ini</filename> a upravili tak, jak + chcete. </para> <para> - On Windows the default path for the <filename>php.ini</filename> - file is the Windows directory. + Pod Windows je soubor <filename>php.ini</filename> implicintì umístìn + v adresáøi systému Windows. </para> </answer> </qandaentry> @@ -49,23 +49,22 @@ <qandaentry id="faq.installation.nodata"> <question> <para> - Unix: I installed PHP, but every time I load a document, I get the - message 'Document Contains No Data'! What's going on here? + UNIX: Nainstaloval jsem PHP, ale v¾dy, kdy¾ naèítám dokument, dostanu + zprávu 'Document Contains No Data'! O co jde? </para> </question> <answer> <para> - This probably means that PHP is having some sort of problem - and is core-dumping. Look in your server error log to see if - this is the case, and then try to reproduce the problem with - a small test case. If you know how to use 'gdb', it is very - helpful when you can provide a backtrace with your bug report - to help the developers pinpoint the problem. If you are using - PHP as an Apache module try something like: + Pravdìpobnì to znamená, ¾e PHP má nìjaký problém a padá. Podívejte se + do protokolu chyb, zda se jedná o tento pøípad a pak zkuste problém + reprodukovat malým testem. Pokud víte, jak pou¾ívat 'gdb', velmi pomù¾e, + kdy¾ mù¾ete s va¹ím hlá¹ením chyby poskytnout výpis (backtrace). + Vývojáøi tak mohou snadnìji lokalizovat problém. Pou¾íváte-li PHP jako + modul do serveru Apache, zkuste nìco jako: <itemizedlist> <listitem> <para> - Stop your httpd processes + Zastavte httpd procesy </para> </listitem> <listitem> @@ -75,7 +74,7 @@ </listitem> <listitem> <para> - Stop your httpd processes + Zastavte httpd procesy </para> </listitem> <listitem> @@ -85,7 +84,7 @@ </listitem> <listitem> <para> - Then fetch the URL causing the problem with your browser + Potom naètìte do prohlí¾eèe URL, kde se vyskytl problém </para> </listitem> <listitem> @@ -95,28 +94,28 @@ </listitem> <listitem> <para> - If you are getting a core dump, gdb should inform you of this now + Dostanete-li core dump (PHP spadne), gdb by vás o tom mìl informovat </para> </listitem> <listitem> <para> - type: bt + napi¹te: bt </para> </listitem> <listitem> <para> - You should include your backtrace in your bug report. This should be submitted to + Získaný výpis (backtrace) byste mìli pøilo¾it k hlá¹ení chyby. + To by se mìlo poslat na <ulink url="&faqurl.php.bugs;">&faqurl.php.bugs;</ulink> </para> </listitem> </itemizedlist> </para> <para> - If your script uses the regular expression functions - (<function>ereg</function> and friends), you should make sure - that you compiled PHP and Apache with the same regular - expression package. This should happen automatically with - PHP and Apache 1.3.x + Pokud vá¹ skript pou¾ívá funkce pro regulární výrazy + (<function>ereg</function> a dal¹í), mìli byste se ujistit, ¾e jste + zkompilovali PHP a Apache se stejným balíèkem pro regulární výrazy. + S PHP a Apachem 1.3.x by se to mìlo dít automaticky. </para> </answer> </qandaentry> @@ -124,15 +123,16 @@ <qandaentry id="faq.installation.processing"> <question> <para> - Unix: I installed PHP using RPMS, but Apache isn't processing the - PHP pages! What's going on here? + UNIX: Instaloval jsem PHP z balíèkù RPM, ale Apache nezpracovává stránky + s PHP! O co tu jde? </para> </question> <answer> <para> - Assuming you installed both Apache and PHP from RPM packages, - you need to uncomment or add some or all of the following lines - in your <filename>http.conf</filename> file: + Za pøedpokladu, ¾e se obojí, jak Apache, tak PHP, instalovalo z + balíèkù RPM, bude tøeba "odkomentovat" nebo pøidat do souboru + <filename>http.conf</filename> nìkteré z následujících øádkù (nebo + v¹echny): <programlisting> # Extra Modules AddModule mod_php.c @@ -141,17 +141,17 @@ # Extra Modules LoadModule php_module modules/mod_php.so -LoadModule php3_module modules/libphp3.so /* for PHP 3 */ -LoadModule php4_module modules/libphp4.so /* for PHP 4 */ +LoadModule php3_module modules/libphp3.so /* pro PHP 3 */ +LoadModule php4_module modules/libphp4.so /* pro PHP 4 */ LoadModule perl_module modules/libperl.so </programlisting> - And add: + Pøidejte také: <programlisting> -AddType application/x-httpd-php3 .php3 /* for PHP 3 */ -AddType application/x-httpd-php .php /* for PHP 4 */ +AddType application/x-httpd-php3 .php3 /* pro PHP 3 */ +AddType application/x-httpd-php .php /* pro PHP 4 */ </programlisting> - ... to the global properties, or to the properties of the - VirtualDomain you want to have PHP support added to. + ... do globálních vlastností nebo do vlastností virtuální domény + (VirtualDomain) by se mìla pøidat podpora PHP. </para> </answer> </qandaentry> @@ -159,37 +159,37 @@ <qandaentry id="faq.installation.compile"> <question> <para> - Unix: I installed PHP 3 using RPMS, but it doesn't compile with - the database support I need! What's going on here? + UNIX: Instaloval jsem PHP 3 z balíèkù RPM, ale nekompiluje se s podporou + databáze, kterou potøebuji! O co tu jde? </para> </question> <answer> <para> - Due to the way PHP 3 built, it is not easy to build a - complete flexible PHP RPM. This issue is addressed in PHP 4. - For PHP 3, we currently suggest you use the mechanism described in the - INSTALL.REDHAT file in the PHP distribution. If you insist on using - an RPM version of PHP 3, read on... + Kvùli tomu, jak se PHP 3 budovalo, není snadné sestavit kompletní + flexibilní RPM balíèek s PHP. Problém je vyøe¹en v PHP 4. Pro PHP 3 + nyní doporuèujeme pou¾ívat mechanismus popsaný v souboru + INSTALL.REDHAT v distribuci PHP. Pokud trváte na pou¾ití RPM verze PHP 3, + ètìte dál... </para> <para> - The RPM packagers are setting up the RPMS to install - without database support to simplify installations <emphasis>and</emphasis> - because RPMS use /usr/ instead of the standard /usr/local/ directory for - files. You need to tell the RPM spec file which databases to support - and the location of the top-level of your database server. + RPM pakovaèe jsou nastaveny na tvorbu RPM balíèkù k instalaci bez + podpory databází kvùli zjednodu¹ení instalací <emphasis>a</emphasis> + proto, ¾e RPM pou¾ívá adresáø /usr/ namísto standardního /usr/local/. + Musít sdìlit RPM souboru spec, které databáze podporovat a umístìní + adresáøe nejvy¹¹í úrovnì databázového serveru. </para> <para> - This example will explain the process of adding support for the - popular MySQL database server, using the mod installation for Apache. + Tento pøíklad vysvìtluje proces pøidání podpory populárního databázového + serveru MySQL, pro instalaci PHP jako modulu do Apache. </para> <para> - Of course all of this information can be adjusted for any database - server that PHP supports. We will assume you installed MySQL and Apache - completely with RPMS for this example as well. + V¹echny tyto informace smaozøejmì mohou být upraveny pro libovolný + databázový server, který PHP podporuje. Pro tento pøíklad budeme + pøedpokládat, ¾e jste instalovali MySQL a Apache plnì z balíèkù RPM. <itemizedlist> <listitem> <para> - First remove mod_php3 : + Nejdøíve odstraòte mod_php3 : <programlisting> rpm -e mod_php3 </programlisting> @@ -197,7 +197,7 @@ </listitem> <listitem> <para> - Then get the source rpm and INSTALL it, NOT --rebuild + Potom vezmìte zdrojový balíèek RPM a spus»te na nìm, NE --rebuild <programlisting> rpm -Uvh mod_php3-3.0.5-2.src.rpm </programlisting> @@ -205,17 +205,19 @@ </listitem> <listitem> <para> - Then edit the <filename>/usr/src/redhat/SPECS/mod_php3.spec</filename> file + Upravte soubor + <filename>/usr/src/redhat/SPECS/mod_php3.spec</filename> </para> <para> - In the %build section add the database support you want, and the path. + V sekci %build pøidejte databázovou podporu, kterou chcete, a nastavte + cestu. </para> <para> - For MySQL you would add + Pro MySQL byste pøidali <programlisting> --with-mysql=/usr \ </programlisting> - The %build section will look something like this: + Sekce %build bude vypadat pøibli¾nì takto: <programlisting> ./configure --prefix=/usr \ --with-apxs=/usr/sbin/apxs \ @@ -230,7 +232,7 @@ </listitem> <listitem> <para> - Once this modification is made then build the binary rpm as follows: + Poté, co jsou provedeny tyto zmìny, zkompilujte balíèek takto: <programlisting> rpm -bb /usr/src/redhat/SPECS/mod_php3.spec </programlisting> @@ -238,17 +240,17 @@ </listitem> <listitem> <para> - Then install the rpm + Potom balíèek nainstalujte: <programlisting> rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm </programlisting> </para> </listitem> </itemizedlist> - Make sure you restart Apache, and you now have PHP 3 with MySQL support - using RPM's. Note that it is probably much easier to just build - from the distribution tarball of PHP 3 and follow the instructions in - <filename>INSTALL.REDHAT</filename> found in that distribution. + Ujistìte se, ¾e jste restartovali Apache, a nyní ji¾ máte PHP 3 s + podporou MySQL. Uvìdomte si, ¾e je pravdìpodobnì mnohem jednodu¹¹í + zkompilovat distribuèní balíèek tar a dr¾et se instrukcí v souboru + <filename>INSTALL.REDHAT</filename> z distribuce. </para> </answer> </qandaentry> @@ -256,17 +258,17 @@ <qandaentry id="faq.installation.frontpage"> <question> <para> - Unix: I patched Apache with the FrontPage extensions patch, and - suddenly PHP stopped working. Is PHP incompatible with the - Apache FrontPage extensions? + UNIX: Pøidal jsem do Apache patch pro FrontPage Extension a PHP náhle + pøestalo pracovat. Je PHP nekompatibilní s FrontPage Extension pro + Apache? </para> </question> <answer> <para> - No, PHP works fine with the FrontPage extensions. The problem - is that the FrontPage patch modifies several Apache structures, - that PHP relies on. Recompiling PHP (using 'make clean ; make') - after the FP patch is applied would solve the problem. + Ne, PHP pracuje dobøe i s FrontPage Extension. Problém je v tom, ¾e + FrontPage patch modifikuje nìkteré struktury Apache, na které PHP + spoléhá. Pøekompilování PHP (pou¾itím 'make clean ; make') po instalaci + FP patche by mìlo problém vyøe¹it. </para> </answer> </qandaentry> @@ -274,18 +276,16 @@ <qandaentry id="faq.installation.blankscreen"> <question> <para> - Unix/Windows: I have installed PHP, but when I try to - access a PHP script file via my browser, I get a blank screen. + UNIX/Windows: Nainstaloval jsem PHP, ale pøi pokusu naèíst soubor PHP + skriptu do prohlí¾eèe se zobrazí pouze prázdná obrazovka. </para> </question> <answer> <para> - Do a 'view source' in the web browser and you will probably - find that you can see the source code of your PHP script. - This means that the web server did not send the script to - PHP for interpretation. Something is wrong with the server - configuration - double check the server configuration against - the PHP installation instructions. + V prohlí¾eèi vyberte funkci 'zobrazit zdrojový kód', nejspí¹ uvidíte + zdrojový kód va¹eho PHP skriptu. To znamená, ¾e server neposílá skript + k interpretaci. Chyba je nìkde v konfiguraci serveru - radìji dvakrát + zkontrolujte konfiguraci podle instrukcí k instalaci PHP. </para> </answer> </qandaentry> @@ -293,24 +293,20 @@ <qandaentry id="faq.installation.500error"> <question> <para> - Unix/Windows: I have installed PHP, but when try to - access a PHP script file via my browser, I get a - server 500 error. + UNIX/Windows: Nainstaloval jsem PHP a kdy¾ chci naèíst PHP soubor do + prohlí¾eèe, objeví se "500 Internal Server Error". </para> </question> <answer> <para> - Something went wrong when the server tried to run PHP. To - get to see a sensible error message, from the command line, - change to the directory containing the PHP executable - (<filename>php.exe</filename> on Windows) and run - <literal>php -i</literal>. If PHP has any problems running, - then a suitable error message will be displayed which will - give you a clue as to what needs to be done next. If you - get a screen full of html codes (the output of the - <function>phpinfo</function> function) then PHP is working, - and your problem may be related to your server configuration - which you should double check. + Pøi pokusu spustit PHP do¹lo k nìjaké chybì. Abyste vidìli detailnìj¹í + chybovou zprávu, z pøíkazové øádky, pøejdìte do adresáøe se souborem + PHP (pod Windows <filename>php.exe</filename>) a spus»te + <literal>php -i</literal>. Pokud pøi bìhu PHP dojde k chybì, bude + zobrazena odpovídající chybovou zpráva, která vám øekne, co se má dál + udìlat. Pokud získáte obrazovku plnou HTML kódu (výstup funkce + <function>phpinfo</function>), pak PHP funguje a vá¹ problém mù¾e + souviset s konfigurací serveru, kterou je pak tøeba dobøe zkontrolovat. </para> </answer> </qandaentry> @@ -318,8 +314,8 @@ <qandaentry id="faq.installation.undefinedsyms"> <question> <para> - Some operating systems: I have installed PHP without errors, - but when I try to start apache I get undefined symbol errors: + Nìkteré operaèní systémy: Nainstaloval jsem PHP bez chyb, ale nyní, + kdy¾ zkusím spustit Apache, ohlásí se chyby o nedefinovaných symbolech: <programlisting> [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: @@ -330,9 +326,9 @@ </question> <answer> <para> - This has actually nothing to do with PHP, but with the MySQL - client libraries. Some need --with-zlib, others do not. This - is also covered in the MySQL FAQ. + To aktuálnì nemá nic spoleèného s PHP, ale s knihovnami klienta MySQL. + Nìkteré potøebují --with-zlib, jiné nikoli. Tímto se zabývá také + MySQL FAQ. </para> </answer> </qandaentry> @@ -340,8 +336,8 @@ <qandaentry id="faq.installation.cgierror"> <question> <para> - Windows: I have installed PHP, but when I to access - a PHP script file via my browser, I get the error: + Windows: Nainstaloval jsem PHP, ale pøi naètení stránky do prohlí¾eèe + se zobrazí chyba: <programlisting> cgi error: The specified CGI application misbehaved by not @@ -352,42 +348,38 @@ </question> <answer> <para> - This error message means that PHP failed to output anything - at all. To get to see a sensible error message, from the - command line, change to the directory containing the PHP - executable (<filename>php.exe</filename> on Windows) and run - <literal>php -i</literal>. If PHP has any problems running, - then a suitable error message will be displayed which will - give you a clue as to what needs to be done next. If you - get a screen full of html codes (the output of the - <function>phpinfo</function> function) then PHP is working. + Tato chybová zpráva znamená, ¾e z PHP nemohou vycházet ¾ádná data. + Abyste vidìli detailnìj¹í + chybovou zprávu, z pøíkazové øádky, pøejdìte do adresáøe se souborem + PHP (pod Windows <filename>php.exe</filename>) a spus»te + <literal>php -i</literal>. Pokud pøi bìhu PHP dojde k chybì, bude + zobrazena odpovídající chybovou zpráva, která vám øekne, co se má dál + udìlat. Pokud získáte obrazovku plnou HTML kódu (výstup funkce + <function>phpinfo</function>), PHP funguje. </para> <para> - Once PHP is working at the command line, try accessing the - script via the browser again. If it still fails then it - could be one of the following: + Jestli¾e PHP pracuje v pøíkazové øádce, zkuste to znovu z prohlí¾eèe. + Pokud to stále nefunguje, mù¾e to být jedním z tìchto dùvodù: </para> <itemizedlist> <listitem> <simpara> - File permissions on your PHP script, + Nastavení pøístupových práv k souboru se skriptem, k <filename>php.exe</filename>, <filename>php4ts.dll</filename>, - <filename>php.ini</filename> or any PHP extensions you are - trying to load are such that the anonymous internet user - <literal>ISUR_<machinename></literal> cannot access them. + <filename>php.ini</filename> nebo nìjakému roz¹íøení PHP, které se + pokou¹íte naèíst, je takové, ¾e k nim anonymní internetový u¾ivatel + <literal>ISUR_<machinename></literal> nemá pøístup. </simpara> </listitem> <listitem> <simpara> - The script file does not exist (or possibly isn't where you - think it is relative to your web root directory). Note that - for IIS you can trap this error by ticking the 'check file - exists' box when setting up the script mappings in the - Internet Services Manager. If a script file does not exist - then the server will return a 404 error instead. There is - also the additional benefit that IIS will do any - authentication required for you based on the NTLanMan - permissions on your script file. + Soubor se skriptem neexistuje (nebo pøípadnì není tam, kde si myslíte, + ¾e je, relativnì ke koøenovému adresáøi webu). Uvìdomte si, ¾e + na IIS mù¾ete tuto chybu zachytit za¹krtnutím volby 'check file + exists' pøi nastavování skriptových slu¾eb v Internet Services + Manageru. Pokud skript neexistuje, server vrátí chybu 404. Dal¹í + výhodou je to, ¾e IIS provede na souboru se skriptem v¹echny potøebné + autentikace zalo¾ené NTLanMan. </simpara> </listitem> </itemizedlist> @@ -397,18 +389,18 @@ <qandaentry id="faq.install.phpandiis"> <question> <para> - Windows: I've followed all the instructions, but still can't - get PHP and IIS to work together! + Windows: Dodr¾el jsem v¹echny instrukce, ale PHP a IIS stále odmítají + spolupracovat! </para> </question> <answer> <para> - Make sure any user who needs to run a PHP script has the rights - to run <filename>php.exe</filename>! IIS uses an anonymous user - which is added at the time IIS is installed. This user needs - rights to <filename>php.exe</filename>. Also, any authenticated - user will also need rights to execute <filename>php.exe</filename>. - And for IIS4 you need to tell it that PHP is a script engine. + Ujistìte se, ¾e ka¾dý u¾ivatel, který potøebuje spou¹tìt PHP skripty má + práva pro spou¹tìní <filename>php.exe</filename>! IIS pou¾ívá anonymního + u¾ivatele, který se pøidá pøi instalaci IIS. Tento u¾ivatel potøebuje + práva k <filename>php.exe</filename>. Také ka¾dý autentikovaný u¾ivatel + bude potøebovat práva na spou¹tìní <filename>php.exe</filename>. + A IIS4 musíte sdìlit, ¾e PHP je skriptovací engine. </para> </answer> </qandaentry> Index: phpdoc/cs/faq/using.xml +++ phpdoc/cs/faq/using.xml <?xml version="1.0" encoding="iso-8859-2"?> <!-- EN-Revision: 1.14 Maintainer: luk Status: ready --> <chapter id="faq.using"> <title>Pou¾ívání PHP</title> <titleabbrev>Pou¾ívání PHP</titleabbrev> <para> Tato èást shrnuje nejèastìj¹í chyby, se kterými se mù¾ete setkat pøi psaní PHP skriptù. </para> <qandaset> <qandaentry id="faq.using.anyform"> <question> <para> Chtìl bych napsat generický PHP skript, který by umìl zpracovat data z jakéhokoli formuláøe. Jak se dozvím, které promìnné metody POST jsou k dispozici? </para> </question> <answer> <para> Ujistìte se, ¾e máte v souboru <filename>php.ini</filename> zapnuto <link linkend="ini.track-vars">track_vars</link> Od PHP 4.0.3 je tato mo¾nost v¾dy zapnuta. Pokud tomu tak je, vytvoøí se nìjaká asociativní pole, z nich¾ nejdùle¾itìj¹í je <literal>$HTTP_POST_VARS</literal>. Tak¾e pro psaní generického skriptu pro obsluhu promìnných metody POST budete potøebovat pøibli¾nì toto: <programlisting role="php"> <![CDATA[ foreach ($HTTP_POST_VARS as $var => $value) { echo "$var = $value<br>\n"; } ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.using.singlequotes"> <question> <para> Potøebuji pøevést v¹echny apostrofy (') na zpìtná lomítka následovaná apostrofy. Jak se to dá udìlat pomocí regulárního výrazu? </para> </question> <answer> <para> Nejdøíve se podívejte na funkci <function>addslashes</function>. Dìlá pøesnì to, co potøebujete. Mìli byste se také podívat na direktivu <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> v souboru <filename>php.ini</filename>. </para> </answer> </qandaentry> <qandaentry id="faq.using.wrong-order"> <question> <para> Kdy¾ napí¹u následující kód, výstup se tiskne v nesprávném poøadí: <programlisting role="php"> function myfunc($argument) { echo $argument + 10; } $variable = 10; echo "myfunc($variable) = " . myfunc($variable); </programlisting> what's going on? </para> </question> <answer> <para> Pro pou¾ití výsledkù va¹í funkce ve výrazu (jako je spojení s jiným øetìzcem v pøíkladu vý¹e), musíte hodnotu <emphasis>vracet</emphasis> (pomocí <emphasis>vracet</emphasis>), ne <function>tisknout</function> (pomocí <function>echo</function>). </para> </answer> </qandaentry> <qandaentry id="faq.using.newlines"> <question> <para> Hej, co se stalo s mými konci øádkù? <programlisting role="php"> <![CDATA[ <pre> <?php echo "Tohle by mìl být první øádek."; ?> <?php echo "Tohle by se mìlo ukázat na novém øádku."; ?> </pre> ]]> </programlisting> </para> </question> <answer> <para> V PHP se blok kódu zakonèuje buï "?>", nebo "?>\n" (kde \n znamená nový øádek). Tak¾e ve vý¹e uvedeném pøíkladu budou vypsané vìty na jediném øádku, proto¾e PHP vynechává konce øádkù za koncem bloku. To znamená, ¾e musíte pøidávat zvlá¹tní konce øádkù za ka¾dý blok PHP kódu, aby se vytisklo odøádkování jediné. </para> <para> Proè to PHP dìlá? Pøi formátování normálního HTML to obvykle zjednodu¹uje ¾ivot, proto¾e nechcete konce øádkù, nýbr¾ chcete vytvoøit extrémnì dlouhé øádky nebo jinak zneèitelnit zdrojový kód. </para> </answer> </qandaentry> <qandaentry id="faq.using.headers-sent"> <question> <para> Zobrazila se mi zpráva 'Warning: Cannot send session cookie - headers already sent...' nebo 'Cannot add header information - headers already sent...'. </para> </question> <answer> <para> Funkce <function>header</function>, <function>set_cookie</function> a funkce session musí do výstupu pøidat hlavièky. Hlavièky je mo¾no posílat pouze pøed vlastním obsahem. Funkce to udìlají, pokud PHP bì¾í jako modul Apache. Následující kus kódu zobrazí v¹echny hlavièky v po¾adavku: <programlisting role="php"> <![CDATA[ $headers = getallheaders(); foreach ($headers as $name => $content) { echo "headers[$name] = $content<br>\n"; } ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.using.header"> <question> <para> Potøebuji pøímo pøistupovat k hlavièce po¾adavku. Jak to udìlat? </para> </question> <answer> <para> Funkce <function>getallheaders</function> to udìlá, pokud PHP bì¾í jako modul do Apache. Následující kus kódu zobrazí v¹echny hlavièky v po¾adavku: <programlisting role="php"> <![CDATA[ $headers = getallheaders(); foreach ($headers as $name => $content) { echo "headers[$name] = $content<br>\n"; } ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.using.authentication"> <question> <para> Kdy¾ zkusím autentikaci s IIS, dostanu 'No Input file specified'. </para> </question> <answer> <para> Bezpeènostní model IIS je s tím na ¹tíru. Je to problém spoleèný v¹em CGI programùm bì¾ícím pod IIS. Øe¹ením je vytvoøit obyèejný HTML soubor (neparsovaný PHP) jako vstupní stránku do autentikovaného adresáøe. Potom se pou¾ije META tag k pøesmìrování na PHP stránku nebo odkaz k ruènímu pøechodu. PHP pak autentikaci zpracuje správnì. S modulem ISAPI toto není problémem. Jiných NT webovských serverù se problém netýká. Více informací - viz <ulink url="&faqurl.iis;">&faqurl.iis;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.using.netscape"> <question> <para> Mùj PHP skript pracuje na IE a Lynxu, ale v Netscapu èást výstupu mizí. Kdy¾ si zapnu "Zobrazit zdrojový kód", v IE vidím obsah, v Netscapu nikoliv. </para> </question> <answer> <para> Netscape je striktnìj¹í ohlednì HTML tagù (napø. tabulek) nì¾ IE. Kontrola HTML výstupu pomocí HTML validátoru, jako je <ulink url="&faqurl.w3.validator;">validator.w3.org</ulink>, mù¾e být nápomocna. Napøíklad chybìjící </table> zpùsobuje vý¹e uvedený problém. </para> <para> IE i Lynx také ignorují jakékoliv nulové (<literal>\0</literal>) znaky v HTML proudu, Netscape nikoli. Nejlep¹í cestou k ovìøení je zkompilovat verzi PHP pro <link linkend="commandline">pøíkazovou øádku</link> (známou jako CGI verze) a spustit skript z pøíkazové øádky. Na *NIXech to pøesmìrujte do <literal>od -c</literal> a hledejte znaky <literal>\0</literal>. Pod Windows musíte najít editor nebo jiný program, který umo¾òuje prohlí¾ení binárních souborù. Kdy¾ Netscape uvidí v souboru nulový znak, typicky nic dal¹ího nezobrazí, aèkoli IE i Lynx ano. </para> </answer> </qandaentry> <qandaentry id="faq.using.mixml"> <question> <para> Jaké jsou pøedpoklady míchání XML a PHP? Stì¾uje si to na moje <?xml> tagy! </para> </question> <answer> <para> Musíte vypnout krátké tagy v souboru <filename>php.ini</filename> nastavením <link linkend="ini.short-open-tag">short_tags</link> na 0 nebo pou¾itím odpovídající direktivy Apache. Mù¾ete také pou¾ít sekci <File> k selektivnímu nastavení. </para> </answer> </qandaentry> <qandaentry id="faq.using.editor"> <question> <para> Jak mohu pou¾ít PHP s FrontPagem nebo jiným HTML editorem, který trvá na odsunutí mého kódu? </para> </question> <answer> <para> Jedním z nejjednodu¹¹ích zpùsobù je povolit pou¾ití ASP tagù v PHP kódu. To umo¾ní pou¾ívat oddìlovaèe v ASP stylu (<% a %>). Nìkteré populární HTML editory s pracují (v tuto chvíli) inteligentnìji. K zapnutí ASP tagù musíte v souboru <filename>php.ini</filename> nastavit promìnnou <link linkend="ini.asp-tags">asp_tags</link> nebo pou¾ít pøíslu¹nou direktivu Apache. </para> </answer> </qandaentry> <qandaentry id="faq.using.variables"> <question> <para> Kde najdi úplný seznam dostupných pøednastavených promìnných, a proè to není zdokumentováno v dokumentaci PHP? </para> </question> <answer> <para> Nejlep¹í metodou je vlo¾it do stránky <literal><?php phpinfo(); ?></literal> a naèíst to do prohlí¾eèe. Zobrazí se informace v¹eho druhu o nainstalovaném PHP, vèetnì seznamu promìnných prostøedí i speciálních promìnných nastavovaných HTTP serverem. Tento seznam opravdu nemù¾e být zdokumentován v dokumentaci k PHP, prot¾e se li¹í server od serveru. </para> </answer> </qandaentry> <qandaentry id="faq.using.cgi-vars"> <question> <para> Zkou¹ím pøistupovat k jedné ze standardních CGI promìnných (jako je $DOCUMENT_ROOT nebo $HTTP_REFERER) v u¾ivatelsky definované funkci, a nemù¾e ji to najít. Co je ¹patnì? </para> </question> <answer> <para> Promìnné prostøedí jsou normální globální promìnné, tak¾e je musíte buï deklarovat ve funkci jako globální promìnné (napøíklad pou¾itím "<literal>global $DOCUMENT_ROOT;</literal>") nebo pou¾ít pole globálních promìnných (napø. "<literal>$GLOBALS["DOCUMENT_ROOT"]</literal>"). </para> </answer> </qandaentry> </qandaset> </chapter> <!-- 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:"../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: --> Index: phpdoc/cs/language/references.xml +++ phpdoc/cs/language/references.xml <?xml version="1.0" encoding="iso-8859-2"?> <!-- EN-Revision: 1.22 Maintainer: luk Status: mixed --> <chapter id="language.references"> <title>Vysvìtlení referencí (odkazù)</title> <sect1 id="language.references.whatare"> <title>Co jsou reference</title> <simpara> References are a means in PHP to access the same variable content by different names. They are not like C pointers, they are symbol table aliases. Note that in PHP, variable name and variable content are different, so the same content can have different names. The most close analogy is with Unix filenames and files - variable names are directory entries, while variable contents is the file itself. References can be thought of as hardlinking in Unix filesystem. </simpara> </sect1> <sect1 id="language.references.whatdo"> <title>What References Do</title> <para> PHP references allow you to make two variables to refer to the same content. Meaning, when you do: <informalexample> <programlisting role="php"> <![CDATA[ $a =& $b ]]> </programlisting> </informalexample> it means that <varname>$a</varname> and <varname>$b</varname> point to the same variable. <note> <para> <varname>$a</varname> and <varname>$b</varname> are completely equal here, that's not <varname>$a</varname> is pointing to <varname>$b</varname> or vice versa, that's <varname>$a</varname> and <varname>$b</varname> pointing to the same place. </para> </note> </para> <para> The same syntax can be used with functions, that return references, and with <literal>new</literal> operator (in PHP 4.0.4 and later): <informalexample> <programlisting role="php"> <![CDATA[ $bar =& new fooclass(); $foo =& find_var ($bar); ]]> </programlisting> </informalexample> </para> <note> <para> Not using the <literal>&</literal> operator causes a copy of the object to be made. If you use <literal>$this</literal> in the class it will operate on the current instance of the class. The assignment without <literal>&</literal> will copy the instance (i.e. the object) and <literal>$this</literal> will operate on the copy, which is not always what is desired. Usually you want to have a single instance to work with, due to performance and memory consumption issues. </para> </note> <para> The second thing references do is to pass variables by-reference. This is done by making a local variable in a function and a variable in the calling scope reference to the same content. Example: <informalexample> <programlisting role="php"> <![CDATA[ function foo (&$var) { $var++; } $a=5; foo ($a); ]]> </programlisting> </informalexample> will make <varname>$a</varname> to be 6. This happens because in the function <varname>foo</varname> the variable <varname>$var</varname> refers to the same content as <varname>$a</varname>. See also more detailed explanations about <link linkend="language.references.pass">passing by reference</link>. </para> <simpara> The third thing reference can do is <link linkend="language.references.return">return by reference</link>. </simpara> </sect1> <sect1 id="language.references.arent"> <title>What References Are Not</title> <para> As said before, references aren't pointers. That means, the following construct won't do what you expect: <informalexample> <programlisting role="php"> <![CDATA[ function foo (&$var) { $var =& $GLOBALS["baz"]; } foo($bar); ]]> </programlisting> </informalexample> </para> <simpara> What happens is that <varname>$var</varname> in <varname>foo</varname> will be bound with <varname>$bar</varname> in caller, but then it will be re-bound with <varname>$GLOBALS["baz"]</varname>. There's no way to bind <varname>$bar</varname> in the calling scope to something else using the reference mechanism, since <varname>$bar</varname> is not available in the function <varname>foo</varname> (it is represented by <varname>$var</varname>, but <varname>$var</varname> has only variable contents and not name-to-value binding in the calling symbol table). </simpara> </sect1> <sect1 id="language.references.pass"> <title>Passing by Reference</title> <para> You can pass variable to function by reference, so that function could modify its arguments. The syntax is as follows: <informalexample> <programlisting role="php"> <![CDATA[ function foo (&$var) { $var++; } $a=5; foo ($a); // $a is 6 here ]]> </programlisting> </informalexample> Note that there's no reference sign on function call - only on function definition. Function definition alone is enough to correctly pass the argument by reference. </para> <para> Following things can be passed by reference: <itemizedlist> <listitem> <simpara> Variable, i.e. <literal>foo($a)</literal> </simpara> </listitem> <listitem> <simpara> New statement, i.e. <literal>foo(new foobar())</literal> </simpara> </listitem> <listitem> <para> Reference, returned from a function, i.e.: <informalexample> <programlisting role="php"> <![CDATA[ function &bar() { $a = 5; return $a; } foo(bar()); ]]> </programlisting> </informalexample> See also explanations about <link linkend="language.references.return">returning by reference</link>. </para> </listitem> </itemizedlist> </para> <para> Any other expression should not be passed by reference, as the result is undefined. For example, the following examples of passing by reference are invalid: <informalexample> <programlisting role="php"> <![CDATA[ function bar() // Note the missing & { $a = 5; return $a; } foo(bar()); foo($a = 5) // Expression, not variable foo(5) // Constant, not variable ]]> </programlisting> </informalexample> These requirements are for PHP 4.0.4 and later. </para> </sect1> <sect1 id="language.references.return"> <title>Returning References</title> <para> Returning by-reference is useful when you want to use a function to find which variable a reference should be bound to. When returning references, use this syntax: <informalexample> <programlisting role="php"> <![CDATA[ function &find_var ($param) { ...code... return $found_var; } $foo =& find_var ($bar); $foo->x = 2; ]]> </programlisting> </informalexample> In this example, the property of the object returned by the <varname>find_var</varname> function would be set, not the copy, as it would be without using reference syntax. </para> <note> <simpara> Unlike parameter passing, here you have to use <literal>&</literal> in both places - to indicate that you return by-reference, not a copy as usual, and to indicate that reference binding, rather than usual assignment, should be done for <varname>$foo</varname>. </simpara> </note> </sect1> <sect1 id="language.references.unset"> <title>Unsetting References</title> <para> When you unset the reference, you just break the binding between variable name and variable content. This does not mean that variable content will be destroyed. For example: <informalexample> <programlisting role="php"> <![CDATA[ $a = 1; $b =& $a; unset ($a); ]]> </programlisting> </informalexample> won't unset <varname>$b</varname>, just <varname>$a</varname>. </para> <simpara> Again, it might be useful to think about this as analogous to Unix <command>unlink</command> call. </simpara> </sect1> <sect1 id="language.references.spot"> <title>Spotting References</title> <simpara> Many syntax constructs in PHP are implemented via referencing mechanisms, so everything told above about reference binding also apply to these constructs. Some constructs, like passing and returning by-reference, are mentioned above. Other constructs that use references are: </simpara> <sect2 id="references.global"> <title><literal>global</literal> References</title> <para> When you declare variable as <command>global $var</command> you are in fact creating reference to a global variable. That means, this is the same as: <informalexample> <programlisting role="php"> <![CDATA[ $var =& $GLOBALS["var"]; ]]> </programlisting> </informalexample> </para> <simpara> That means, for example, that unsetting <varname>$var</varname> won't unset global variable. </simpara> </sect2> <sect2 id="references.this"> <title><literal>$this</literal></title> <simpara> In an object method, <varname>$this</varname> is always reference to the caller object. </simpara> </sect2> </sect1> </chapter> <!-- 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:"../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: -->