PHP3 Frequently Asked Questions

$Id$

This is a list of Frequently Asked Questions about PHP3 and their answers. If you have suggestions or additions, send them to php3@php.il.eu.org.


General Information

What is PHP3?

From the manual:

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.

What is its relation to PHP/FI?

PHP3 is the successor to PHP/FI 2.0.

What are the differences between PHP3 and PHP/FI 2.0?

For a complete list of the changes, read the CHANGES file included in the PHP3 distribution. Some highlights:

Is there a PHP3 mailing list?

Of course! To subscribe, send mail to php3-subscribe@php.il.eu.org. You don't need to include anything special in the subject or body of the message.

To unsubscribe, send mail to php3-unsubscribe@php.il.eu.org.

Help! I can't seem to subscribe to the mailing list!

Help! I can't seem to unsubscribe from the mailing list!

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 joeblow@example.com, you can send your subscription request to php3-subscribe-joeblow=example.com@php.il.eu.org, or your unsubscription request to php3-unsubscribe-joeblow=example.com@php.il.eu.org.

Is there an archive of the mailing list anywhere?

Yes, it's located at http://www.tryc.on.ca/php3.html.


Obtaining PHP3

Where can I obtain PHP3?

You can download PHP3 from any of the members of the PHP3 network of sites. These can be found at http://www.php.net/.

Why do I have to register to download PHP3?

This is so the development team can find out what operating systems and databases that people are using, and how many people are using PHP3 in general. Don't worry, you aren't being added to any mailing lists by registering!

Where can I get libraries needed to compile php modules

How do I get these libraries work?

You will need to follow instructions provided with the library.

Are pre-compiled binary versions available?

Yes, as long as you're looking for binaries for Windows 95 or NT. They're available in the same place as the source.


Installation

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.

Common Problems

When I run configure, it says that it can't find the include files or library for gdbm (or some other package)!
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:
            CFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
    
If you're using a csh-variant for your login shell (why?), it would be:
            env CFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
    

When it is compiling the file language-parser.tab.c, it gives me errors that say 'yytname undeclared'.
You need to update your version of Bison.

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.
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 "cp *.o functions" and then re-running 'make' to see if that helps. If it does, you should really upgrade to a recent version of GNU make.

When linking PHP3, it complains about a number of undefined references.
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.

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.

Some people have reported that they had to add '-ldl' immediately following 'libphp3.a' when linking with Apache.


Using PHP3

Common Problems

I installed PHP3, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here?
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.

If your script using the regular expression functions (ereg() 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.)

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?
Environment variables are now normal global variables, so you must either declare them as global variables in your function (by using "global $DOCUMENT_ROOT;", for example) or by using the global variable array (ie, "$GLOBAL["DOCUMENT_ROOT"]".

I think I found a bug! Who should I tell?

You should use the bug-reporting form located on any of the PHP3 network members. For example, try going to http://www.php.net/bug-form.php3.


Migrating from PHP/FI 2.0

Common Problems

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!
You probably missed the semi-colon on a while (condition); 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.

My user-functions don't work any more! I get a "Parse error (expecting '('" on the first line of the function.
PHP3's function declaration now resembles C function declarations, so your function should look like:
        function printsum($a, $b) {
           echo $a + $b;
        }
    

You can also use old-style function declarations by use the 'old_function' designation, like so:

        old_function printsum $a, $b (
           echo $a + $b;
        );
    


Credits

This FAQ was originally written by Jim Winstead. It is currently maintained by the PHP Development Team.