mirror of
https://github.com/php/web-php.git
synced 2026-03-28 09:12:17 +01:00
463 lines
19 KiB
HTML
463 lines
19 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>PHP3 Frequently Asked Questions</TITLE>
|
|
<STYLE type="text/css">
|
|
BODY {background: #FFFFFF}
|
|
H1,H2,H3 {color: blue}
|
|
</STYLE>
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
|
|
<H1>PHP3 Frequently Asked Questions</H1>
|
|
|
|
<!-- The website should stop chopping. -->
|
|
|
|
<P>This is a list of Frequently Asked Questions about PHP3 and
|
|
their answers. If you have suggestions or additions, send them to
|
|
<CODE>php3@php.il.eu.org</CODE>.
|
|
|
|
<HR>
|
|
|
|
<H2>General Information</H2>
|
|
|
|
<H3>What is PHP3?</H3>
|
|
|
|
<P>From the <A href="http://www.php.net/manual/manual.html">manual</A>:
|
|
|
|
<BLOCKQUOTE>
|
|
<P>Professional Home Pages Version 3.0 is an HTML-embedded scripting
|
|
language. Much of its syntax is borrowed from C, Java and Perl with a
|
|
couple of unique PHP-specific features thrown in. The goal of the language
|
|
is to allow web developers to write dynamically generated pages quickly.
|
|
</BLOCKQUOTE>
|
|
|
|
<H3>What is its relation to PHP/FI?</H3>
|
|
|
|
PHP3 is the successor to PHP/FI 2.0.
|
|
|
|
<H3>What are the differences between PHP3 and PHP/FI 2.0?</H3>
|
|
|
|
<P>For a complete list of the changes, read the <A href="changes.php3">CHANGES</A>
|
|
file included in the PHP3 distribution. Some highlights:
|
|
|
|
<UL>
|
|
<LI>All-new parser.
|
|
<LI>Persistent database connections.
|
|
</UL>
|
|
|
|
<H3>I heard it's possible to access Microsoft SQL Server from PHP3. How?</H3>
|
|
|
|
<P>On Windows 95/NT machines, you can simply use the included ODBC support
|
|
and the correct ODBC driver.
|
|
|
|
<P>On Unix machines, you can use the Sybase-CT driver to access Microsoft
|
|
SQL Servers because they are (at least mostly) protocol-compatible. Sybase
|
|
has made a <a href="/extra/ctlib-linux-elf.tar.gz">free version of the necessary libraries for Linux systems</a>.
|
|
For other Unix operating systems, you need to contact Sybase for the correct
|
|
libraries (which cost money).
|
|
|
|
<H3>Can I access Microsoft Access databases?</H3>
|
|
|
|
<P>Yes. You already have all the tools you need if you are running
|
|
entirely under Windows 95 or NT, where you can use ODBC and Microsoft's
|
|
ODBC drivers for Microsoft Access databases. From other platforms, you
|
|
would need to have a server running Windows NT (or possibly Windows 95)
|
|
which you connected to using ODBC drivers from your other platform and
|
|
<A href="http://www.openlinksw.com/">OpenLink Software's ODBC Agent</A>
|
|
software, which runs US$4,000.
|
|
|
|
<P>Some better alternatives are to use an SQL server that has Windows ODBC
|
|
drivers and use that to store the data, which you can then access from
|
|
Microsoft Access (using ODBC) and PHP3 (using the built-in drivers), or
|
|
to use an intermediary file format that Access and PHP3 both understand,
|
|
such as flat-files or dBase databases.
|
|
|
|
<H3>I saw PHP3 offers persistent database connections. What does that mean?</H3>
|
|
|
|
<p>Persistent connections are SQL links that do not close when the
|
|
execution of your script ends. When a persistent connection is requested,
|
|
PHP checks if there's already an identical persistent connection (that
|
|
remained open from earlier) - and if it exists, it uses it. If it does
|
|
not exist, it creates the link. An 'identical' connection is a connection
|
|
that was opened to the same host, with the same username and the same
|
|
password (where applicable).
|
|
|
|
<p>People who aren't thoroughly familiar with the way Web servers work and
|
|
distribute the load may mistake persistent connects for what they're not.
|
|
In particular, they do NOT give you an ability to open 'user sessions' on
|
|
the same SQL link, they do NOT give you an ability to build up a transaction
|
|
efficently, and they don't do a whole lot of other things. In fact, to be
|
|
extremely clear about the subject, persistent connections don't give you ANY
|
|
functionality that wasn't possible with their non-persistent brothers.
|
|
|
|
<p>Why?
|
|
<p>This has to do with the way the way Web servers work. We can divide
|
|
PHP to three main types. First, PHP in its CGI mode. In CGI mode, there's
|
|
no difference between persistent and non persistent connects. The reason is
|
|
simple - a CGI binary terminates as soon as the execution of your script ends.
|
|
Obviously, when it dies, any resource it may have 'owned', including any type
|
|
of SQL link, dies with it (in practice PHP is nicer and properly closes the
|
|
SQL link right before it dies, but even if it didn't, the link wouldn't have
|
|
been reusable).
|
|
|
|
<p>The second way of running PHP is as a plugin for a *multithreaded* server.
|
|
Currently, this is only theoratical - Shane has a thread safe ISAPI module
|
|
in the works, and NSAPI/Win32 will probably follow soon after the ISAPI one
|
|
works right. Multithreaded servers are a bit different in what they enable
|
|
developers to do, even though as far as I can tell right now, PHP's behavior
|
|
would be identical to the one of *multiprocess* servers. See below.
|
|
|
|
<p>The last, and most popular way of running PHP is as a plugin to the
|
|
multiprocess server - apache. A quick guide to the way apache (usually)
|
|
works - apache has one 'parent' process, that doesn't answer to requests.
|
|
Its job is to coordinate between its children. The children, which are
|
|
spawned by the parent, are the processes that answer to HTTP requests. The
|
|
load of the requests is divided among all of the children. That is, two
|
|
subsequent hits on the same page are likely to be handled by TWO DIFFERENT
|
|
PROCESSES. This is the key issue here. There are plenty of processes that
|
|
make the 'Web server', and the load is distributed among them.
|
|
|
|
<p>What does that have to do with persistent connections? Everything. That
|
|
explains why there's no added functionality in persistent connections. When
|
|
you open a persistent connection, you can't do something like beginning a
|
|
transaction, and hope that the next time the user submits a page you'd just
|
|
continue the transaction. You can't lock tables and hope that the next hit
|
|
by the user will unlock the tables. The two requests are most likely to be
|
|
handled by two different processes!
|
|
|
|
<p>If persistent connections don't have any added functionality, what are
|
|
they good for?
|
|
<p>The answer here is extremely simple - efficiency. Persistent connections
|
|
are good if the overhead to create a link to your SQL server is high.
|
|
Whether or not this overhead is really high depends on many factors. Like,
|
|
what kind of database it is, whether or not it sits on the same computer on
|
|
which your web server sits, how loaded the machine the SQL server sits on is
|
|
and so forth. The bottom line is that IF that connection overhead is high,
|
|
persistent connects help you. They simply connect only once for the entire
|
|
lifespan of the httpd child, instead of once per hit that child processes.
|
|
Make sure you understand - this means that for every child that opened a
|
|
persistent connection will have its own open persistent connection to the
|
|
server. That is, if you had 20 different httpd processes that ran a script
|
|
that included a pconnect(), you'd have 20 different connections to the SQL
|
|
server, one from each child.
|
|
|
|
<p>An important summary. pconnects were designed to have 1::1 mapping to
|
|
regular connects. That means that you should ALWAYS be able to replace
|
|
persistent connect with a non-persistent connect, and it won't change the
|
|
way the script behaves. It MAY and probably will change the efficiency of
|
|
the script, but not its behavior!
|
|
|
|
<H3>Is there a PHP3 mailing list?</H3>
|
|
|
|
<P>Of course! To subscribe, send mail to
|
|
<CODE>php3-subscribe@php.il.eu.org</CODE>. You don't need to include
|
|
anything special in the subject or body of the message.
|
|
|
|
<P>To unsubscribe, send mail to
|
|
<CODE>php3-unsubscribe@php.il.eu.org</CODE>.
|
|
|
|
<H3>Help! I can't seem to subscribe to the mailing list!</H3>
|
|
<H3>Help! I can't seem to unsubscribe from the mailing list!</H3>
|
|
|
|
<P>If you have problems subscribing to or unsubscribing from the PHP3
|
|
mailng list, it may be because the mailing list software can't figure
|
|
out the correct mailing address to use. If your email address was
|
|
<CODE>joeblow@example.com</CODE>, you can send your subscription request
|
|
to <CODE>php3-subscribe-joeblow=example.com@php.il.eu.org</CODE>,
|
|
or your unsubscription request to
|
|
<CODE>php3-unsubscribe-joeblow=example.com@php.il.eu.org</CODE>.
|
|
|
|
<H3>Is there an archive of the mailing list anywhere?</H3>
|
|
|
|
<P>Yes, it's located at <A
|
|
href="http://www.tryc.on.ca/php3.html">http://www.tryc.on.ca/php3.html</A>.
|
|
|
|
<HR>
|
|
|
|
<H2>Obtaining PHP3</H2>
|
|
|
|
<H3>Where can I obtain PHP3?</H3>
|
|
|
|
<P>You can download PHP3 from any of the members of the
|
|
PHP3 network of sites. These can be found at <A
|
|
href="http://www.php.net/">http://www.php.net/</A>.
|
|
You can also use anonymous CVS to get the absolute latest
|
|
version of the source. For more information, go to <A
|
|
href="http://www.lerdorf.on.ca/php3.cgi">http://www.lerdorf.on.ca/php3.cgi</A>.
|
|
|
|
<H3>Where can I get libraries needed to compile some of the optional
|
|
PHP3 extensions?</H3>
|
|
|
|
<P>Note: Those marked with * are not thread-safe libraries, and should
|
|
not be used with PHP3 as a server module in the multi-threaded Windows web
|
|
servers (IIS, Netscape). This does not matter in Unix environments, yet.
|
|
|
|
<UL>
|
|
<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>
|
|
<LI>LDAP* (win): <A href="ftp://terminator.rs.itd.umich.edu/ldap/windows/winldap.zip">ftp://terminator.rs.itd.umich.edu/ldap/windows/winldap.zip</A><br>
|
|
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>.
|
|
<LI>Berkeley DB2 (Unix/Win): <A href="http://www.sleepycat.com/">http://www.sleepycat.com/</A>
|
|
<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.)
|
|
<LI>GD* (Unix/Win): <A href="http://www.boutell.com/gd/#buildgd">http://www.boutell.com/gd/#buildgd</A>
|
|
<LI>mSQL (Unix): <A href="http://www.hughes.com.au/">http://www.hughes.com.au/</A>
|
|
<LI>mSQL* (Win) : <A HREF="http://blnet.com/msqlpc/">MSQL PC Home Page</a>
|
|
<LI>MySQL (Unix): <A href="http://www.tcx.se/">http://www.tcx.se/</A>
|
|
<LI>IMAP* (Win/Unix): <A HREF="ftp://ftp.cac.washington.edu/imap/imap-4.1.BETA.tar.Z">ftp://ftp.cac.washington.edu/imap/imap-4.1.BETA.tar.Z</a>
|
|
<LI>Sybase-CT (Linux, libc5): <a href="/extra/ctlib-linux-elf.tar.gz">Available locally</a>
|
|
</UL>
|
|
|
|
<H3>How do I get these libraries to work?</H3>
|
|
|
|
<P>You will need to follow instructions provided with the library. Some of
|
|
these libraries are detected automatically when you run the 'configure'
|
|
script of PHP3 (such as the GD library), and others you will have to
|
|
enable using '--with-EXTENSION' options to 'configure'. Run 'configure
|
|
--help' for a listing of these.
|
|
|
|
<H3>Are pre-compiled binary versions available?</H3>
|
|
|
|
<P>Yes, as long as you're looking for binaries for Windows 95 or NT.
|
|
They're available in the same place as the source.
|
|
|
|
<H3>I got the latest version of the PHP3 source code from the CVS
|
|
repository on my Windows 95/NT machine, what do I need to compile it?</H3>
|
|
|
|
<P>First, you will need Microsoft Visual C++ v5 (v4 may
|
|
do it also, but we do it with v5), and you will need to <A
|
|
href="http://www.php.net/win32/makeparser.zip">download Bison and
|
|
Flex</A>. You will need to put Bison and Flex somewhere in your path,
|
|
or add their location to your path. Then run the batch file 'makeparser'
|
|
before compiling with MSVC. You also may need to edit some settings
|
|
in the project settings. You should be familier enough with MSVC to
|
|
know what to do ;).
|
|
|
|
<HR>
|
|
|
|
<H2>Installation</H2>
|
|
|
|
<P>To install PHP3, follow the instructions in the INSTALL file located
|
|
in the distribution. Windows 95 and NT users should also read the
|
|
README.WIN32 file.
|
|
|
|
<H3>Common Problems</H3>
|
|
|
|
<DL>
|
|
<DT><B>
|
|
I got the latest version of PHP3 using the anonymous CVS service,
|
|
but there's no configure script!
|
|
</B></DT>
|
|
<DD>
|
|
You have to have the GNU autoconf package installed so you can
|
|
generate the configure script from configure.in. Just run
|
|
<CODE>autoconf</CODE> in the top-level directory after getting
|
|
the sources from the CVS server. (Also, unless you run configure
|
|
with the <CODE>--enable-maintainer-mode</CODE> option, the
|
|
configure script will not automatically get rebuilt when the
|
|
configure.in file is updated, so you should make sure to do that
|
|
manually when you notice configure.in has changed. One symptom
|
|
of this is finding things like @VARIABLE@ in your Makefile after
|
|
configure or config.status is run.
|
|
<P>
|
|
</DD>
|
|
<DT><B>
|
|
I'm having problems configuring PHP3 to work with Apache. It says
|
|
it can't find httpd.h, but it's right where I said it is!
|
|
</B></DT>
|
|
<DD>
|
|
You need to tell the configure/setup script the location of the
|
|
<EM>top-level</EM> of your Apache source tree. This means that
|
|
you want to specify '<CODE>--with-apache=/path/to/apache</CODE>'
|
|
and <EM>not</EM> '<CODE>--with-apache=/path/to/apache/src</CODE>'.
|
|
<P>
|
|
</DD>
|
|
<DT><B>
|
|
When I run configure, it says that it can't find the include files or
|
|
library for gdbm (or some other package)!
|
|
</B></DT>
|
|
<DD>
|
|
You can make the configure script looks for header files and libraries
|
|
in non-standard locations by specifying additional flags to pass to
|
|
the C compiler, such as:
|
|
<PRE>
|
|
CFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
|
|
</PRE>
|
|
If you're using a csh-variant for your login shell (why?), it would be:
|
|
<PRE>
|
|
env CFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
|
|
</PRE>
|
|
<P>
|
|
</DD>
|
|
|
|
<DT><B>
|
|
When it is compiling the file language-parser.tab.c, it gives me errors
|
|
that say 'yytname undeclared'.
|
|
</B></DT>
|
|
<DD>
|
|
You need to update your version of Bison. You can find the latest version
|
|
at <A href="ftp://prep.ai.mit.edu/pub/gnu/">ftp://prep.ai.mit.edu/pub/gnu/</A>.
|
|
<P>
|
|
</DD>
|
|
|
|
<DT><B>
|
|
When I run 'make', it seems to run fine but then fails when it
|
|
tries to link the final application complaining that it can't find
|
|
some files.
|
|
</B></DT>
|
|
<DD>
|
|
Some old versions of make that don't correctly put the compiled
|
|
versions of the files in the functions directory into that same
|
|
directory. Try running "<CODE>cp *.o functions</CODE>" and then
|
|
re-running 'make' to see if that helps. If it does, you should really
|
|
upgrade to a recent version of GNU make.
|
|
<P>
|
|
</DD>
|
|
|
|
<DT><B>
|
|
When linking PHP3, it complains about a number of undefined references.
|
|
</B></DT>
|
|
<DD>
|
|
Take a look at the link line and make sure that all of the appropriate
|
|
libraries are being included at the end. Common ones that you might have
|
|
missed are '-ldl' and any libraries required for any database support
|
|
you included.
|
|
<P>
|
|
If you're linking with Apache 1.2.x, did you remember to add the
|
|
appropriate information to the EXTRA_LIBS line of the Configuration
|
|
file and re-rerun Apache's Configure script? See the INSTALL file that
|
|
comes with the distribution for more information.
|
|
<P>
|
|
Some people have also reported that they had to add '-ldl' immediately
|
|
following 'libphp3.a' when linking with Apache.
|
|
<P>
|
|
</DD>
|
|
|
|
<DT><B>
|
|
I can't figure out how to build PHP3 with Apache 1.3.
|
|
</B></DT>
|
|
<DD>
|
|
<P>This is actually quite easy. Follow these steps carefully:
|
|
<UL>
|
|
<LI>Grab the latest Apache 1.3 distribution from <A href="http://www.apache.org/dist/">www.apache.org</A>.
|
|
<LI>Ungzip and untar it somewhere, for example /usr/local/src/apache_1.3b3.
|
|
<LI>Compile PHP3 by first running ./configure --with-apache=/<i><path></i>/apache_1.3b3 (substitute <i><path></i> for the actual path to your apache_1.3b3 directory.
|
|
<LI>Type 'make' followed by 'make install' to build PHP3 and copy the
|
|
necessary files to the Apache distribution tree.
|
|
<LI>Change directories into to your /<i><path></i>/apache_1.3b3/src directory and edit the <i>Configuration</i> file. At the end of the file, add: <tt>AddModule modules/extra/mod_php3.o</tt>.
|
|
<LI>Type: './Configure' followed by 'make'.
|
|
<LI>You should now have a PHP3-enabled httpd binary!
|
|
</UL>
|
|
<P>
|
|
</DD>
|
|
</DL>
|
|
|
|
<HR>
|
|
|
|
<H2>Using PHP3</H2>
|
|
|
|
<H3>Common Problems</H3>
|
|
|
|
<DL>
|
|
<DT><b>
|
|
I installed PHP3, but every time I load a document, I get the
|
|
message 'Document Contains No Data'! What's going on here?
|
|
</b></DT>
|
|
<DD>
|
|
This probably means that PHP3 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.
|
|
<P>
|
|
If your script uses the regular expression functions (<CODE>ereg()</CODE>
|
|
and friends), you should make sure that you compiled PHP3 and
|
|
Apache with the same regular expression package. (This should
|
|
happen automatically with PHP3 and Apache 1.3.)
|
|
<P>
|
|
</DD>
|
|
|
|
<DT><B>
|
|
I'm trying to access one of the standard CGI variables (such
|
|
as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined function,
|
|
and it can't seem to find it. What's wrong?
|
|
</B></DT>
|
|
<DD>
|
|
Environment variables are now normal global variables, so you must
|
|
either declare them as global variables in your function (by using
|
|
"<CODE>global $DOCUMENT_ROOT;</CODE>", for example) or by using
|
|
the global variable array (ie, "<CODE>$GLOBALS["DOCUMENT_ROOT"]</CODE>".
|
|
<P>
|
|
</DD>
|
|
</DL>
|
|
|
|
<H3>I think I found a bug! Who should I tell?</H3>
|
|
|
|
<P>You should go to the PHP Bug Database and make sure
|
|
the bug isn't a known bug. If you don't see it in the database,
|
|
use the reporting form to report the bug. It is important to use
|
|
the bug database as opposed to just sending an email to one
|
|
of the mailing lists because by using the database the bug will
|
|
get an id assigned and it will then be possible for you to go back
|
|
later and check on the status of the bug. The bug database
|
|
can be found at <a href="http://ca.php.net/bugs.php3">http://ca.php.net/bugs.php3</a>.
|
|
|
|
<HR>
|
|
|
|
<H2>Migrating from PHP/FI 2.0</H2>
|
|
|
|
<H3>Common Problems</H3>
|
|
|
|
<DL>
|
|
<DT><B>
|
|
I converted my script from PHP/FI 2.0 to PHP3 syntax, but now it just
|
|
hangs! When I looked at the processes running on my server, there was
|
|
one process that was chewing up all of the CPU cycles!
|
|
</B></DT>
|
|
<DD>
|
|
You probably missed the semi-colon on a <CODE>while
|
|
(condition);</CODE> statement. This will cause PHP3 to spin out of
|
|
control because it is simply executing an empty body for your while
|
|
loop! Change the semi-colon to a colon and it should work correctly.
|
|
<P>
|
|
</DD>
|
|
|
|
<DT><B>
|
|
My user-functions don't work any more! I get a "Parse error (expecting '('"
|
|
on the first line of the function.
|
|
</B></DT>
|
|
<DD>
|
|
PHP3's function declaration now resembles C function declarations, so
|
|
your function should look like:
|
|
<PRE>
|
|
function printsum($a, $b) {
|
|
echo $a + $b;
|
|
}
|
|
</PRE>
|
|
<P>You can also use old-style function declarations by use the
|
|
'old_function' designation, like so:
|
|
<PRE>
|
|
old_function printsum $a, $b (
|
|
echo $a + $b;
|
|
);
|
|
</PRE>
|
|
<P>
|
|
</DD>
|
|
</DL>
|
|
|
|
<HR>
|
|
|
|
<H2>Credits</H2>
|
|
|
|
<P>This FAQ was originally written by Jim Winstead. It is currently
|
|
maintained by the PHP Development Team.
|
|
|
|
<P>
|
|
<SMALL>
|
|
<CODE>$Id$</CODE>
|
|
</SMALL>
|
|
|
|
<!-- The website should start chopping again. -->
|
|
</BODY>
|
|
</HTML>
|