]> git.pld-linux.org Git - packages/php.git/blob - FAQ.php
- started 4.3.8 for RA
[packages/php.git] / FAQ.php
1 <!-- X-URL: http://www.php.net/FAQ.php3 -->
2 <BASE HREF="http://www.php.net/FAQ.php3">
3
4 <HTML>
5 <HEAD>
6 <TITLE>PHP3: Frequently Asked Questions</TITLE>
7
8
9 <SCRIPT LANGUAGE="JavaScript">
10 <!--
11 var loaded = 0;
12 var gotlayers = 0;
13 var lastbutton='top';
14
15 function popUp(menuName,on) {
16 }
17 function moveLayers() {
18 }
19
20
21
22 function change(Name,No) {
23 }
24 function changebullet(Name,No) {
25 }
26 function hide() {
27 }
28
29
30 //--->
31 </SCRIPT>
32
33 </HEAD>
34
35 <BODY MARGINHEIGHT=3 MARGINWIDTH=3 TOPMARGIN=3 LEFTMARGIN=3 BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#5B69A6" VLINK="#5B69A6" ALINK="#00FF00"
36 ><A NAME="top">
37 <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
38  <TR valign=top>
39   <TD ALIGN=left width=150 BGCOLOR="#5B69A6">
40    <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="150">
41     <TR VALIGN=top>
42      <TD ALIGN=left>
43       <IMG SRC="/gifs/cap-ul.gif" WIDTH=9 HEIGHT=9 BORDER=0><BR>
44       <IMG SRC='/gifs/spacer.gif' WIDTH=15 HEIGHT=67 BORDER=0 ALT=' '><A HREF="/index.php3"><IMG SRC="/gifs/logo.gif" ALT="PHP3 Home Page" WIDTH=130 HEIGHT=67 BORDER=0></A><BR>
45       <IMG SRC='/gifs/spacer.gif' WIDTH=1 HEIGHT=10 BORDER=0 ALT=' '><BR>
46      </TD>
47     </TR>
48     <TR VALIGN=top>
49      <TD ALIGN=left>
50         <A HREF="downloads.php3" onMouseover="change('down',1);" 
51  onMouseout="hide();"><IMG SRC="/gifs/b-downloads-p.gif" 
52  ALT="Downloads" 
53  WIDTH=129 HEIGHT=30 BORDER=0 
54  NAME="down" 
55  HSPACE=10 VSPACE=0></A><BR>
56 <A HREF="docs.php3" onMouseover="change('docs',1);" 
57  onMouseout="hide();"><IMG SRC="/gifs/b-docs-p.gif" 
58  ALT="Documentation" 
59  WIDTH=129 HEIGHT=30 BORDER=0 
60  NAME="docs" 
61  HSPACE=10 VSPACE=0></A><BR>
62 <A HREF="support.php3" onMouseover="change('dev',1);" 
63  onMouseout="hide();"><IMG SRC="/gifs/b-development-p.gif" 
64  ALT="Getting Help" 
65  WIDTH=129 HEIGHT=30 BORDER=0 
66  NAME="dev" 
67  HSPACE=10 VSPACE=0></A><BR>
68 <A HREF="news.php3" onMouseover="change('news',1);" 
69  onMouseout="hide();"><IMG SRC="/gifs/b-news-p.gif" 
70  ALT="PHP News last updated: Jun 10, 1998" 
71  WIDTH=129 HEIGHT=30 BORDER=0 
72  NAME="news" 
73  HSPACE=10 VSPACE=0></A><BR>
74 <A HREF="projects.php3" onMouseover="change('proj',1);" 
75  onMouseout="hide();"><IMG SRC="/gifs/b-projects-p.gif" 
76  ALT="Projects using PHP" 
77  WIDTH=129 HEIGHT=30 BORDER=0 
78  NAME="proj" 
79  HSPACE=10 VSPACE=0></A><BR>
80 <A HREF="links.php3" onMouseover="change('link',1);" 
81  onMouseout="hide();"><IMG SRC="/gifs/b-links-p.gif" 
82  ALT="PHP Links" 
83  WIDTH=129 HEIGHT=30 BORDER=0 
84  NAME="link" 
85  HSPACE=10 VSPACE=0></A><BR>
86 <A HREF="mirrors.php3" onMouseover="change('mirr',1); popUp('mirrorsKick',true);" 
87  ><IMG SRC="/gifs/b-mirror-p.gif" 
88  ALT="Mirror sites" 
89  WIDTH=129 HEIGHT=30 BORDER=0 
90  NAME="mirr" 
91  HSPACE=10 VSPACE=0></A><BR>
92      </TD>
93     </TR>
94    </TABLE>
95   </TD>
96   <TD align=left width="100%">
97    <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width="100%">
98     <TR VALIGN=middle BGCOLOR="#5B69A6">
99      <TD ALIGN=left>
100       <IMG SRC='/gifs/spacer.gif' WIDTH=5 HEIGHT=1 BORDER=0 ALT=' '><FONT FACE="tahoma, verdana, arial, helvetica, sans-serif" SIZE=4><B>Frequently Asked Questions</B></FONT><BR>
101      </TD>
102      <TD ALIGN=right>
103       <IMG SRC="/gifs/b-close-p.gif" 
104  ALT="" 
105  WIDTH=1 HEIGHT=1 BORDER=0 
106  NAME="close" 
107  HSPACE=0 VSPACE=0><A HREF="/source.php3?page_url=/FAQ.php3" onMouseover="change('sour',1);" 
108  onMouseout="hide();"><IMG SRC="/gifs/b-source-p.gif" 
109  ALT="View the source code for this page" 
110  WIDTH=75 HEIGHT=30 BORDER=0 
111  NAME="sour" 
112  HSPACE=5 VSPACE=9></A><A HREF="/search.php3" onMouseover="change('sear',1); popUp('searchKick',true);" 
113  ><IMG SRC="/gifs/b-search-p.gif" 
114  ALT="Search the site" 
115  WIDTH=75 HEIGHT=30 BORDER=0 
116  NAME="sear" 
117  HSPACE=5 VSPACE=9></A><IMG SRC="/gifs/cap-right.gif" WIDTH=24 HEIGHT=48 BORDER=0><BR></TD>
118     </TR>
119    </TABLE>
120    <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width="100%">
121     <TR VALIGN=top BGCOLOR="#FFFFFF">
122      <TD ALIGN=left WIDTH="12">
123       <IMG SRC="/gifs/corner-ul.gif" WIDTH=12 HEIGHT=12 BORDER=0><BR>
124      </TD>
125      <TD ALIGN=left WIDTH="100%">
126             <FONT FACE="tahoma, verdana, arial, helvetica, sans-serif">
127             <BR CLEAR=ALL>
128       <!-- start body -->
129
130 <P>This is a list of Frequently Asked Questions about PHP3 and
131 their answers. If you have suggestions or additions, send them to
132 <CODE>php3@lists.php.net</CODE>.
133
134 <HR noshade>
135
136 <H2>General Information</H2>
137
138 <DL>
139   <DT><B>
140     What is PHP3?
141   </B></DT>
142   <DD>
143     From the <A href="http://www.php.net/manual/">manual</A>:
144
145     <BLOCKQUOTE>
146     <P>PHP Version 3.0 is an HTML-embedded scripting
147     language. Much of its syntax is borrowed from C, Java and Perl with a
148     couple of unique PHP-specific features thrown in. The goal of the language
149     is to allow web developers to write dynamically generated pages quickly.
150     </BLOCKQUOTE>
151   <P>
152   </DD>
153
154   <DT><B>
155     What is its relation to PHP/FI?
156   </B></DT>
157   <DD>
158     PHP3 is the successor to PHP/FI 2.0.
159   <P>
160   </DD>
161   <DT><B>
162     Can I run both PHP/FI 2.0 and PHP3 at the same time?
163   </B></DT>
164   <DD>
165     Yes, PHP3 was written so as to not interfere with an existing PHP/FI 2 installation.
166     Instructions for building Apache 1.3.0 with both PHP/FI 2 and PHP3 modules can be
167     found <a href="php2.php3">HERE</a>.
168   <P>
169
170   <DT><B>
171     What are the differences between PHP3 and PHP/FI 2.0?
172   </B></DT>
173   <DD>
174     For a complete list of the changes, read the <A
175     href="changes.php3">CHANGES</A> file included in the PHP3
176     distribution. Some highlights:
177
178     <UL>
179       <LI>All-new parser.
180       <LI>Persistent database connections.
181       <LI>A native Windows95/NT port.
182       <LI>IMAP, SNMP, and LDAP extensions.
183     </UL>
184   <P>
185   </DD>
186
187   <DT><B>
188     I heard it's possible to access Microsoft SQL Server from PHP3. How?
189   </B></DT>
190   <DD>
191     On Windows 95/NT machines, you can simply use the included ODBC support
192     and the correct ODBC driver.
193
194     <P>On Unix machines, you can use the Sybase-CT driver
195     to access Microsoft SQL Servers because they are (at
196     least mostly) protocol-compatible. Sybase has made a <A
197     href="/extra/ctlib-linux-elf.tar.gz">free version of the necessary
198     libraries for Linux systems</A>.  For other Unix operating systems,
199     you need to contact Sybase for the correct libraries (which cost
200     money).
201   <P>
202   </DD>
203
204   <DT><B>
205     Can I access Microsoft Access databases?
206   </B></DT>
207   <DD>
208     Yes. You already have all the tools you need if you are running
209     entirely under Windows 95 or NT, where you can use ODBC and Microsoft's
210     ODBC drivers for Microsoft Access databases. From other platforms, you
211     would need to have a server running Windows NT (or possibly Windows 95)
212     which you connected to using ODBC drivers from your other platform and
213     <A href="http://www.openlinksw.com/">OpenLink Software's ODBC Agent</A>
214     software, which runs US$4,000.
215
216     <P>Some better alternatives are to use an SQL server that has
217     Windows ODBC drivers and use that to store the data, which you can
218     then access from Microsoft Access (using ODBC) and PHP3 (using the
219     built-in drivers), or to use an intermediary file format that Access
220     and PHP3 both understand, such as flat-files or dBase databases.
221   <P>
222   </DD>
223
224   <DT><B>
225     Is there a PHP3 mailing list?
226   </B></DT>
227   <DD>
228     Of course! To subscribe, send mail to
229     <CODE>php3-subscribe@lists.php.net</CODE>. You don't need to include
230     anything special in the subject or body of the message.
231
232     <P>To unsubscribe, send mail to <CODE>php3-unsubscribe@lists.php.net</CODE>.
233   <P>
234   </DD>
235
236   <DT><B>
237     Help! I can't seem to subscribe to the mailing list!
238   </B></DT>
239   <DT><B>
240     Help! I can't seem to unsubscribe from the mailing list!
241   </B></DT>
242   <DD>
243     If you have problems subscribing to or unsubscribing from the
244     PHP3 mailng list, it may be because the mailing list software
245     can't figure out the correct mailing address to use. If
246     your email address was <CODE>joeblow@example.com</CODE>,
247     you can send your subscription request to
248     <CODE>php3-subscribe-joeblow=example.com@lists.php.net</CODE>,
249     or your unsubscription request to
250     <CODE>php3-unsubscribe-joeblow=example.com@lists.php.net</CODE>.
251   <P>
252   </DD>
253
254   <DT><B>
255     Is there an archive of the mailing list anywhere?
256   </B></DT>
257   <DD>
258     Yes, it's located at <A
259     href="http://www.tryc.on.ca/php3.html">http://www.tryc.on.ca/php3.html</A>.
260   </DD>
261 </DL>
262
263 <HR noshade>
264
265 <H2>Obtaining PHP3</H2>
266
267 <DL>
268   <DT><B>
269     Where can I obtain PHP3?
270   </B></DT>
271   <DD>
272     You can download PHP3 from any of the members of the
273     PHP3 network of sites. These can be found at <A
274     href="http://www.php.net/">http://www.php.net/</A>.
275     You can also use anonymous CVS to get the absolute latest
276     version of the source. For more information, go to <A
277     href="http://ca.php.net/cvsweb.cgi">http://ca.php.net/cvsweb.cgi</A>.
278   <P>
279   </DD>
280
281   <DT><B>
282     Are pre-compiled binary versions available?
283   </B></DT>
284   <DD>
285     Yes, as long as you're looking for binaries for Windows 95 or NT.
286     They're available in the same place as the source.
287   <P>
288   </DD>
289
290   <DT><B>
291     Where can I get libraries needed to compile some of the optional
292     PHP3 extensions?
293   </B></DT>
294   <DD>
295     <B>Note:</B> Those marked with * are not thread-safe libraries, and
296     should not be used with PHP3 as a server module in the multi-threaded
297     Windows web servers (IIS, Netscape).  This does not matter in Unix
298     environments, yet.
299
300     <UL>
301       <LI>LDAP* (unix): <A href="ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z">ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z</A>
302       <LI>LDAP (unix/win): <A HREF="http://developer.netscape.com/tech/directory/downloads.html" TARGET="_top">Netscape Directory (LDAP) SDK 1.1</A>
303           There is also a free LDAP server at: <A href="ftp://ftp.critical-angle.com/pub/cai/slapd/">ftp://ftp.critical-angle.com/pub/cai/slapd/</A>.
304       <LI>Berkeley DB2 (Unix/Win): <A href="http://www.sleepycat.com/">http://www.sleepycat.com/</A>
305       <LI>SNMP* (Unix): <A href="http://www.ece.ucdavis.edu/ucd-snmp/">http://www.ece.ucdavis.edu/ucd-snmp/</A> (Note: PHP3 uses the native SNMP interface in Windows.)
306       <LI>GD* (Unix/Win): <A href="http://www.boutell.com/gd/#buildgd">http://www.boutell.com/gd/#buildgd</A> 
307       <LI>mSQL* (Unix): <A href="http://www.hughes.com.au/">http://www.hughes.com.au/</A> 
308       <LI>mSQL* (Win) : <A HREF="http://blnet.com/msqlpc/">MSQL PC Home Page</a>
309       <LI>MySQL (Unix): <A href="http://www.tcx.se/">http://www.tcx.se/</A>
310       <LI>IMAP* (Win/Unix): <A HREF="ftp://ftp.cac.washington.edu/imap/old/imap-4.tar.Z">ftp://ftp.cac.washington.edu/imap/old/imap-4.tar.Z</A>
311       <LI>Sybase-CT* (Linux, libc5):  <A href="/extra/ctlib-linux-elf.tar.gz">Available locally</A>
312       <LI>FreeType: <A HREF="http://www.physiol.med.tu-muenchen.de/~robert/freetype.html">http://www.physiol.med.tu-muenchen.de/~robert/freetype.html</A>
313           <LI>ZLib (Unix/Win32): <A HREF="http://www.cdrom.com/pub/infozip/zlib/">http://www.cdrom.com/pub/infozip/zlib/</a>
314     </UL>
315   <P>
316   </DD>
317
318   <DT><B>
319     How do I get these libraries to work?
320   </B></DT>
321   <DD>
322     You will need to follow instructions provided with the library. Some of
323     these libraries are detected automatically when you run the 'configure'
324     script of PHP3 (such as the GD library), and others you will have to
325     enable using '--with-EXTENSION' options to 'configure'. Run 'configure
326     --help' for a listing of these.
327   <P>
328   </DD>
329
330   <DT><B>
331     I got the latest version of the PHP3 source code from the CVS
332     repository on my Windows 95/NT machine, what do I need to compile it?
333   </B></DT>
334   <DD>
335     First, you will need Microsoft Visual C++ v5 (v4 may do
336     it also, but we do it with v5), and you will need to <A
337     href="http://www.php.net/win32/makeparser.zip">download Bison and
338     Flex</A>.  You will need to put Bison and Flex somewhere in your
339     path, or add their location to your path.  Then run the batch file
340     'makeparser' before compiling with MSVC.  You also may need to edit
341     some settings in the project settings.  You should be familier enough
342     with MSVC to know what to do ;).
343   <P>
344   </DD>
345 </DL>
346
347   <DT><B>
348     Where do I find the Browser Capabilities File?
349   </B></DT>
350   <DD>
351     You can find PHP's own browscap.ini file at <a href="http://php.netvision.net.il/browscap/">http://php.netvision.net.il/browscap/</a>.
352         There is also another browscap.ini file at <a href="http://www.cyscape.com/asp/browscap/">http://www.cyscape.com/asp/browscap/</a>.
353   <P>
354   </DD>
355
356 <HR noshade>
357
358 <H2>Installation</H2>
359
360 <P>To install PHP3, follow the instructions in the <A
361 href="http://ca.php.net/cvsweb.cgi/INSTALL?rev=1.18">INSTALL</A>
362 file located in the distribution. Windows
363 95 and NT users should also read the <A
364 href="http://ca.php.net/cvsweb.cgi/README.WIN32?rev=1.3">README.WIN32</A>
365 file.  There are also some helpful hints for Windows users here:
366 <a href="http://leonard.staff.imaginet.fr/Doc/php/configuration_NT.html">
367 http://leonard.staff.imaginet.fr/Doc/php/configuration_NT.html</a>.
368
369 <H3>Common Problems</H3>
370
371 <DL>
372   <DT><B>
373     I got the latest version of PHP3 using the anonymous CVS service,
374     but there's no configure script!
375   </B></DT>
376   <DD>
377     You have to have the GNU autoconf package installed so you can
378     generate the configure script from configure.in. Just run
379     <CODE>autoconf</CODE> in the top-level directory after getting
380     the sources from the CVS server. (Also, unless you run configure
381     with the <CODE>--enable-maintainer-mode</CODE> option, the
382     configure script will not automatically get rebuilt when the
383     configure.in file is updated, so you should make sure to do that
384     manually when you notice configure.in has changed. One symptom
385     of this is finding things like @VARIABLE@ in your Makefile after
386     configure or config.status is run.
387   <P>
388   </DD>
389   <DT><B>
390     I'm having problems configuring PHP3 to work with Apache. It says
391     it can't find httpd.h, but it's right where I said it is!
392   </B></DT>
393   <DD>
394     You need to tell the configure/setup script the location of the
395     <EM>top-level</EM> of your Apache source tree. This means that
396     you want to specify '<CODE>--with-apache=/path/to/apache</CODE>'
397     and <EM>not</EM> '<CODE>--with-apache=/path/to/apache/src</CODE>'.
398   <P>
399   </DD>
400   <DT><B>
401     When I run configure, it says that it can't find the include files or
402     library for GD, gdbm, or some other package!
403   </B></DT>
404   <DD>
405     You can make the configure script looks for header files and libraries
406     in non-standard locations by specifying additional flags to pass to
407     the C preprocessor and linker, such as:
408 <FONT FACE="monospaced"><PRE>
409     CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
410 </PRE></FONT>
411     If you're using a csh-variant for your login shell (why?), it would be:
412 <FONT FACE="monospaced"><PRE>
413     env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
414 </PRE></FONT>
415   <P>
416   </DD>
417
418   <DT><B>
419     When it is compiling the file language-parser.tab.c, it gives me errors
420     that say 'yytname undeclared'.
421   </B></DT>
422   <DD>
423     You need to update your version of Bison. You can find the latest version
424     at <A href="ftp://prep.ai.mit.edu/pub/gnu/">ftp://prep.ai.mit.edu/pub/gnu/</A>.
425   <P>
426   </DD>
427             
428   <DT><B>
429     When I run 'make', it seems to run fine but then fails when it
430     tries to link the final application complaining that it can't find
431     some files.
432   </B></DT>
433   <DD>
434     Some old versions of make that don't correctly put the compiled
435     versions of the files in the functions directory into that same
436     directory. Try running "<CODE>cp *.o functions</CODE>" and then
437     re-running 'make' to see if that helps. If it does, you should really
438     upgrade to a recent version of GNU make.
439   <P>
440   </DD>
441
442   <DT><B>
443     When linking PHP3, it complains about a number of undefined references.
444   </B></DT>
445   <DD>
446     Take a look at the link line and make sure that all of the appropriate
447     libraries are being included at the end. Common ones that you might have
448     missed are '-ldl' and any libraries required for any database support
449     you included.
450     <P>
451     If you're linking with Apache 1.2.x, did you remember to add the
452     appropriate information to the EXTRA_LIBS line of the Configuration
453     file and re-rerun Apache's Configure script? See the <A href="http://ca.php.net/cvsweb.cgi/INSTALL?rev=1.18">INSTALL</A> file that
454     comes with the distribution for more information.
455     <P>
456     Some people have also reported that they had to add '-ldl' immediately
457     following 'libphp3.a' when linking with Apache.
458   <P>
459   </DD>
460
461   <DT><B>
462         I can't figure out how to build PHP3 with Apache 1.3.
463   </B></DT>
464   <DD>
465     <P>This is actually quite easy.  Follow these steps carefully:
466     <UL>
467         <LI>Grab the latest Apache 1.3 distribution from <A href="http://www.apache.org/dist/">www.apache.org</A>.
468         <LI>Ungzip and untar it somewhere, for example /usr/local/src/apache-1.3.
469         <LI>Compile PHP3 by first running ./configure --with-apache=/<i>&lt;path&gt;</i>/apache-1.3  (substitute <i>&lt;path&gt;</i> for the actual path to your apache-1.3 directory.
470         <LI>Type 'make' followed by 'make install' to build PHP3 and copy the
471             necessary files to the Apache distribution tree.
472         <LI>Change directories into to your /<i>&lt;path&gt;</i>/apache-1.3/src directory and edit the <i>Configuration</i> file.  At the end of the file, add: <tt>AddModule modules/php3/libphp3.a</tt>.
473         <LI>Type: './Configure' followed by 'make'.
474         <LI>You should now have a PHP3-enabled httpd binary!
475     </UL>
476     <b>Note:</b> You can also use the new Apache ./configure script.  See the instructions in the README.configure file
477     which is part of your Apache distribution.  Also have a look at the INSTALL file in the PHP distribution.
478   <P>
479   </DD>
480 </DL>
481
482 <HR noshade>
483
484 <H2>Using PHP3</H2>
485
486 <DL>
487   <DT><B>
488     I would like to write a generic PHP script that can handle data coming
489     from any form.  How do I know which POST method variables are available?
490   </B></DT>
491   <DD>
492     You need to compile PHP with the "--enable-track-vars" configure switch.
493     This creates three associative arrays.  $HTTP_GET_VARS, $HTTP_POST_VARS
494     and $HTTP_COOKIE_VARS.  So, to write a generic script to handle POST
495     method variables you would need something similar to the following:<PRE>
496     while (list($var, $value) = each($HTTP_POST_VARS)) {
497         echo "$var = $value&lt;br&gt;n";
498     }</PRE>
499   <P>
500   </DD>
501
502   <DT><B>
503     I need to convert all single-quotes (') to a backslash followed by
504     a single-quote. How can I do this with a regular expression?
505   </B></DT>
506   <DD>
507     First off, take a look at the <A href="manual/function.addslashes.php3">addslashes()</A> function. It will do
508     exactly what you want.
509   <P>
510     The ereg_replace magic you're looking for, however, is simply:<PRE>
511     $escaped = ereg_replace("'", "\'", $input);</PRE>
512   <P>
513   </DD>
514
515   <DT><B>
516     When I do the following, the output is printed in the wrong order:<PRE>
517       function myfunc($argument) {
518         echo $myfunc + 10;
519       }
520       $variable = 10;
521       echo "myfunc($variable) = " . myfunc($variable);
522     </PRE>
523     <P>What's going on?
524   </B></DT>
525   <DD>
526     To be able to use the results of your function in an expression (such
527     as concatenating it with other strings in the example above), you need
528     to <B>return</B> the value, not echo it.
529   <P>
530   </DD>
531
532   <DT><B>
533     Hey, what happened to my newlines in:
534 <PRE>
535 &lt;PRE&gt;
536   1 &lt;?echo $result[1];?&gt;
537   2 &lt;?echo $result[2];?&gt;
538 </PRE>
539   </B></DT>
540   <DD>
541     In PHP, the ending for a block of code is either "?&gt;" <B>or</B>
542     "?&gt;n" (where n means a newline). This means that you need to
543     insert an extra newline after each block of PHP code in the above
544     example.
545     <P>
546     Why does PHP do this? Because when formatting normal HTML, this
547     usually makes your life easier because you don't want that newline,
548     but you'd have to create extremely long lines or otherwise make the
549     raw page source unreadable to achieve that effect.
550   <P>
551   </DD>
552
553   <DT><B>
554     I need to access information in the request header directly.  How can
555     I do this?
556   </B></DT>
557   <DD>
558     The getallheaders() function will do this if you are running PHP as a
559     module.  So, the following bit of code will show you all the request
560     headers:<PRE>
561     $headers = getallheaders();
562         for(reset($headers); $key = key($headers); next($headers)) {
563         echo "headers[$key] = ".$headers[$key]."&lt;br&gt;n";
564     }
565 </PRE>
566   <P>
567   </DD>
568
569   <DT><B>
570     When I try to use authentication with IIS I get 'No Input file specified'
571   </B></DT>
572   <DD>
573     The security model of IIS is at fault here. This is a problem
574     common to all CGI programs running under IIS.  A workaround is
575     to create a plain HTML file (not parsed by php) as the entry page
576     into an authenticated directory.  Then use a META tag to redirect
577     to the PHP page, or have a link to the PHP page.  PHP will
578     then recognize the authentication correctly.  When the ISAPI
579     module is ready, this will no longer be a problem.  This should
580     not effect other NT web servers.  For more information, see: <A
581     href="http://support.microsoft.com/support/kb/articles/q160/4/22.asp"
582     target="_new">http://support.microsoft.com/support/kb/articles/q160/4/22.asp</A>.
583   <P>
584   </DD>
585
586   <DT><B>
587     I've followed all the instructions, but still can't get PHP and IIS
588     to work together!
589   </B></DT>
590   <DD>
591     Make sure any user who needs to run a PHP script has the rights
592     to run php.exe!  IIS uses an anonymous user which is added at the
593     time IIS is installed.  This user needs rights to php.exe.  Also,
594     any authenticated user will also need rights to execute php.exe.
595   <P>
596   </DD>
597
598 </DL>
599
600 <H3>New Features</H3>
601
602 <DL>
603   <DT><B>
604     I saw PHP3 offers persistent database connections.   What does that mean?
605   </B></DT>
606   <DD>
607     Persistent connections are SQL links that do not close when the
608     execution of your script ends.  When a persistent connection is
609     requested, PHP checks if there's already an identical persistent
610     connection (that remained open from earlier) - and if it exists, it
611     uses it.  If it does not exist, it creates the link.  An 'identical'
612     connection is a connection that was opened to the same host, with
613     the same username and the same password (where applicable).
614
615     <P>People who aren't thoroughly familiar with the way web servers
616     work and distribute the load may mistake persistent connects for what
617     they're not.  In particular, they do <B>not</B> give you an ability
618     to open 'user sessions' on the same SQL link, they do <B>not</B>
619     give you an ability to build up a transaction efficently, and they
620     don't do a whole lot of other things.  In fact, to be extremely
621     clear about the subject, persistent connections don't give you <B>any</B>
622     functionality that wasn't possible with their non-persistent brothers.
623
624     <P>Why?
625
626     <P>This has to do with the way web servers work. There are three ways
627     in which your web server can utilize PHP to generate web pages.
628
629     <P>The first method is to use PHP as a CGI "wrapper". When run this
630     way, an instance of the PHP interpreter is created and destroyed for
631     every page request (for a PHP page) to your web server. Because it
632     is destroyed after every request, any resources that it acquires (such
633     as a link to an SQL database server) are closed when it is destroyed.
634     In this case, you do not gain anything from trying to use persistent
635     connections -- they simply don't persist.
636
637     <P>The second, and most popular, method is to run PHP as a module
638     in a <I>multiprocess</I> web server, which currently only includes
639     Apache. A multiprocess server typically has one process (the parent)
640     which coordinates a set of processes (its children) who actually do
641     the work of serving up web pages. When each request comes in from a a
642     client, it is handed off to one of the children that is not already
643     serving another client. This means that when the same client makes
644     a second request to the server, it may be serviced by a different
645     child process than the first time. What a persistent connection does
646     for you in this case it make it so each child process only needs
647     to connect to your SQL server the first time that it serves a page
648     that makes us of such a connection. When another page then requires
649     a connection to the SQL server, it can reuse the connection that
650     child established earlier.
651
652     <P>The last method is to use PHP as a plug-in for a <I>multithreaded</I>
653     web server. Currently this is only theoretical -- PHP does not
654     yet work as a plug-in for any multithreaded web servers. Work is
655     progressing on support for ISAPI, WSAPI, and NSAPI (on Windows),
656     which will all allow PHP to be used as a plug-in on multithreaded
657     servers like Netscape FastTrack, Microsoft's Internet Information
658     Server (IIS), and O'Reilly's WebSite Pro. When this happens, the
659     behavior will be essentially the same as for the multiprocess model
660     described before.
661
662     <P>If persistent connections don't have any added functionality,
663     what are they good for?
664
665     <P>The answer here is extremely simple -- efficiency.  Persistent
666     connections are good if the overhead to create a link to your SQL
667     server is high.  Whether or not this overhead is really high depends
668     on many factors.  Like, what kind of database it is, whether or
669     not it sits on the same computer on which your web server sits,
670     how loaded the machine the SQL server sits on is and so forth.
671     The bottom line is that if that connection overhead is high,
672     persistent connections help you considerably.  They cause the child
673     process to simply connect only once for its entire lifespan, instead
674     of every time it processes a page that requires connecting to the
675     SQL server.  This means that for every child that opened a persistent
676     connection will have its own open persistent connection to the server.
677     For example, if you had 20 different child processes that ran a script
678     that made a persistent connection to your SQL server, you'd have 20
679     different connections to the SQL server, one from each child.
680
681     <P>An important summary.  Persistent connections were designed to
682     have one-to-one mapping to regular connections.  That means that you
683     should <B>always</B> be able to replace persistent connections with
684     non-persistent connections, and it won't change the way your script
685     behaves.  It <B>may</B> (and probably will) change the efficiency
686     of the script, but not its behavior!
687   <P>
688   </DD>
689 </DL>
690
691 <H3>Common Problems</H3>
692
693 <DL>
694   <DT><b>
695     I installed PHP3, but every time I load a document, I get the
696     message 'Document Contains No Data'! What's going on here?
697   </b></DT>
698   <DD>
699     This probably means that PHP3 is having some sort of problem
700     and is core-dumping. Look in your server error log to see if
701     this is the case, and then try to reproduce the problem with
702     a small test case. If you know how to use 'gdb', it is very
703     helpful when you can provide a backtrace with your bug report
704     to help the developers pinpoint the problem.
705     <P>
706     If your script uses the regular expression functions (<CODE>ereg()</CODE>
707     and friends), you should make sure that you compiled PHP3 and
708     Apache with the same regular expression package. (This should
709     happen automatically with PHP3 and Apache 1.3.)
710   <P>
711   </DD>
712
713   <DT><B>
714     I'm trying to access one of the standard CGI variables (such
715     as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined function,
716     and it can't seem to find it. What's wrong?
717   </B></DT>
718   <DD>
719     Environment variables are now normal global variables, so you must
720     either declare them as global variables in your function (by using
721     "<CODE>global $DOCUMENT_ROOT;</CODE>", for example) or by using
722     the global variable array (ie, "<CODE>$GLOBALS["DOCUMENT_ROOT"]</CODE>".
723   <P>
724   </DD>
725
726   <DT><B>
727     I think I found a bug! Who should I tell?
728   </B></DT>
729   <DD>
730     You should go to the PHP Bug Database and make sure the bug
731     isn't a known bug.  If you don't see it in the database, use
732     the reporting form to report the bug.  It is important to use
733     the bug database instead of just sending an email to one of the
734     mailing lists because the bug will have a tracking number assigned
735     and it will then be possible for you to go back later and check
736     on the status of the bug.  The bug database can be found at <A
737     href="http://ca.php.net/bugs.php3">http://ca.php.net/bugs.php3</A>.
738   <P>
739   </DD>
740 </DL>
741
742 <HR noshade>
743
744 <H2>Migrating from PHP/FI 2.0</H2>
745
746 <H3>Common Problems</H3>
747
748 <DL>
749   <DT><B>
750     When I add two strings together and then echo it, it echoes zero instead
751     of the concatenation of the two strings! What's going on? Wouldn't it
752     be great if adding two strings just concatenated them together?
753   </B></DT>
754   <DD>
755     PHP3 does not support the overloading of the addition operator for
756     strings because values that arrive via the GET and POST methods and
757     from databases are always stored as strings. This means that if the
758     plus operator were overloaded to concatenate strings, you could add
759     what you thought were two numbers and get the wrong result! (For
760     example, "4" + "5" would be equal to "45".) One way around this would
761     be to explicitly type-cast one or both of the operands, which is what
762     PHP/FI 2 did.
763
764    <P>This has been simplified in PHP3 by the addition of a real string
765    concatenation operator. If you want to "add" two strings together,
766    just write it like: <CODE>"this" . "that"</CODE> which will result in
767    the string "thisthat".
768
769    <P>The answer to the final part of the question is an emphatic no.
770    Operator overloading can be a source of great confusion, especially
771    when variables aren't very strongly typed to begin with, as they are
772    in PHP3.
773   <P>
774   </DD>
775
776   <DT><B>
777     When I use the chmod(), umask(), or mkdir() functions, the permissions
778     are wrong!
779   </B></DT>
780   <DD>
781     Unlike PHP/FI 2, PHP3 does not interpret the numeric arguments for
782     these functions any differently than for any other function, which
783     means you need to pass in an octal value if you are specifying an
784     octal number, such as:
785 <PRE>
786         chmod($myfile, 0600);
787 </PRE>
788     <B>not</B>
789 <PRE>
790         chmod($myfile, 600);
791 </PRE>
792   <P>
793   </DD>
794
795   <DT><B>
796     I converted my script from PHP/FI 2.0 to PHP3 syntax, but now it just
797     hangs! When I looked at the processes running on my server, there was
798     one process that was chewing up all of the CPU cycles!
799   </B></DT>
800   <DD>
801     You probably missed the semi-colon on a <CODE>while
802     (condition);</CODE> statement. This will cause PHP3 to spin out of
803     control because it is simply executing an empty body for your while
804     loop!  Change the semi-colon to a colon and it should work correctly.
805   <P>
806   </DD>
807
808   <DT><B>
809     My user-functions don't work any more! I get a "Parse error (expecting '('"
810     on the first line of the function.
811   </B></DT>
812   <DD>
813     PHP3's function declaration now resembles C function declarations, so
814     your function should look like:
815     <PRE>
816         function printsum($a, $b) {
817            echo $a + $b;
818         }
819     </PRE>
820     <P>You can also use old-style function declarations by use the 
821     'old_function' designation, like so:
822     <PRE>
823         old_function printsum $a, $b (
824            echo $a + $b;
825         );
826     </PRE>
827     <P>
828     </DD>
829 </DL>
830
831 <HR noshade>
832
833 <H2>Credits</H2>
834
835 <P>This FAQ was originally written by Jim Winstead. It is currently
836 maintained by the PHP Development Team.
837
838 <P>
839       <!-- end body -->
840      </TD>
841     </TR>
842    </TABLE>
843   </TD>
844  </TR>
845  <TR valign=top BGCOLOR="#5B69A6">
846   <TD ALIGN=left width="150">
847    <IMG SRC='/gifs/spacer.gif' WIDTH=150 HEIGHT=1 BORDER=0 ALT=' '><BR>
848   </TD>
849   <TD ALIGN=left width="100%" BGCOLOR="#FFFFFF">
850    <IMG SRC="/gifs/corner-bl.gif" WIDTH=12 HEIGHT=12 BORDER=0><BR>
851   </TD>
852  </TR>
853  <TR valign=top>
854   <TD ALIGN=left width="150" BGCOLOR="#5B69A6">
855    <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="150">
856     <TR VALIGN=bottom>
857      <TD ALIGN=left>
858       <IMG SRC='/gifs/spacer.gif' WIDTH=1 HEIGHT=3 BORDER=0 ALT=' '><BR>
859 <A HREF="/credits.php3" onMouseover="change('cred',1);" 
860  onMouseout="hide();"><IMG SRC="/gifs/b-credits-p.gif" 
861  ALT="Who's responsible for this?" 
862  WIDTH=129 HEIGHT=30 BORDER=0 
863  NAME="cred" 
864  HSPACE=10 VSPACE=0></A><BR>
865 <A HREF="#top" onMouseover="change('top',1);" 
866  onMouseout="hide();"><IMG SRC="/gifs/b-top-p.gif" 
867  ALT="Top of this page" 
868  WIDTH=129 HEIGHT=30 BORDER=0 
869  NAME="top" 
870  HSPACE=10 VSPACE=0></A><BR>
871       <IMG SRC="/gifs/cap-bl.gif" WIDTH=9 HEIGHT=9 BORDER=0><BR>
872      </TD>
873     </TR>
874    </TABLE>
875   </TD>
876   <TD align=left width="100%">
877    <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width="100%">
878     <TR VALIGN=middle>
879      <TD ALIGN=center BGCOLOR="#5B69A6">
880       <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
881        <TR VALIGN=middle>
882         <TD align=right>
883          <FONT FACE="tahoma, verdana, arial, helvetica, sans-serif" SIZE=1>
884          <I>Site<BR>Hosting:</I><BR>
885         </TD>
886         <TD>
887          <IMG SRC='/gifs/spacer.gif' WIDTH=5 HEIGHT=1 BORDER=0 ALT=' '><BR>
888         </TD>
889         <TD>
890          <A HREF="http://BestHost.net/"><IMG SRC="/gifs/logo-besthost.gif" WIDTH=190 HEIGHT=48 BORDER=0 vspace=12></A><BR>
891         </TD>
892        </TR>
893       </TABLE>
894      </TD>
895      <TD ALIGN=right BGCOLOR="#5B69A6">
896       <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
897        <TR VALIGN=middle>
898         <TD align=center>
899 <FONT  FACE="tahoma, verdana, arial, helvetica, sans-serif" SIZE=2>
900 <FONT SIZE=1><I>Located in</I></FONT><BR>United States    </TD>
901         <TD><IMG SRC='/gifs/spacer.gif' WIDTH=5 HEIGHT=1 BORDER=0 ALT=' '></TD>
902         <TD>
903          <IMG SRC="/gifs/flag-us.gif" BORDER=0></TD>
904         <TD>
905          <IMG SRC="/gifs/cap-right2.gif" WIDTH=24 HEIGHT=72 BORDER=0></TD>
906        </TR>
907       </TABLE>
908      </TD>
909     </TR>
910    </TABLE>
911   </TD>
912  </TR>
913 </TABLE>
914
915 </BODY>
916 </HTML>
This page took 0.158635 seconds and 3 git commands to generate.