Pages

Mar 16, 2010

Intalling PHP (Part Final)


Error Reporting Directives

To diagnose bugs in your code, you should enable the directive that allows error
messages to be written to the browser. This is on by default:
display_errors = On
You can also set the level of error reporting. We will cover the options available for
the error_reporting directive in more depth in Hour 22. For now, however, you
should set this to the following:
error_reporting = E_ALL & ~ E_NOTICE
This will report all errors but not notices that warn about potential problems with
your code. Notices can interfere with some PHP techniques. This setting is the
default.
Variable Directives
PHP makes certain variables available to you as a result of a GET request, a POST
request, or a cookie. You can influence this in the php.ini file.
The track_vars directive creates associative arrays containing elements generated
as a result of an HTTP request. This is allowed by default:
track_vars = On
The register_globals directive determines whether values resulting from an HTTP
request should be made available as global variables. Many scripts in this book will
require the following setting to be enabled:
register_globals = On

Help!


Help is always at hand on the Internet, particularly for problems concerning open
source software. Wait a moment before you hit the send button, however. No
matter how intractable your installation, configuration, or programming problem
might seem, chances are you are not alone. Someone will have already answered
your question.
When you hit a brick wall, your first recourse should be to the official PHP site at
, particularly the annotated manual at
.
If you still can't find your answer, don't forget that the PHP site is searchable. The
advice you are seeking may be lurking in a press release or a Frequently Asked
Questions file. Another excellent and searchable resource is the PHP Knowledge
Base at .
Still no luck? You can find links to searchable mailing list archives at
. These archives represent a huge
information resource with contributions from many of the great and the good in the
PHP community. Spend some time trying out a few keyword combinations.
If you are still convinced that your problem has not been addressed, you may well
be doing the PHP community a service by exposing it.
You can join the PHP mailing lists at .
Although these lists are often high volume, you can learn a lot from them. If you are
serious about PHP scripting, you should certainly subscribe at least to a digest list .
Once subscribed to the list that matches your concerns, you might consider posting
your problem.
When you post a question it is often a good idea to include as much information as
possible (without writing a novel). The following items often are pertinent:
Your operating system
The version of PHP you are running or installing
The configure options you chose
Any output from the configure or make commands that preceded an installation
failure
A reasonably complete example of the code that is causing you problems
Why all these cautions about posting a question to a mailing list? First, developing
research skills will stand you in good stead. A good researcher can generally solve a
problem quickly and efficiently. Asking a naive question of a technical list often
involves a wait rewarded only by a message or two referring you to the archives
where you should have begun your search for answers.
Second, remember that a mailing list is not analogous to a technical support call
center. No one is paid to answer your questions. Despite this, you have access to an
impressive resource of talent and knowledge, including that of some of the creators
of PHP itself. A good question and its answer will be archived to help other coders.
Asking a question that has been answered several times just adds more noise.
Having said this, don't be afraid to post a problem to the list. PHP developers are a
civilized and helpful breed, and by bringing a problem to the attention of the
community, you might be helping others to solve the same problem.

Summary

PHP4 is open source software. It is also open in the sense that it does not demand
that you use a particular server, operating system, or database.
In this hour, you learned where to locate PHP and other open source software that
can help you host and serve Web sites. You learned how to compile PHP as an
Apache module on Linux. If you download a PHP binary for another platform, your
distribution will contain step-by-step instructions. You learned some of the
configure options that can change the features that your binary will support. You
learned about php.ini and some of the directive it contains. Finally, you learned
about sources of support. You should now be ready to come to grips with the
language itself.

Q&A


Q You have covered an installation for Linux and Apache. Does that mean
that this book will not apply to my server and operating system?
A No, one of PHP's great strengths is that it runs on multiple platforms. If you are
having trouble installing PHP to work on your operating system or with your server,
don't forget to read the files that come with your PHP distribution. You should find
comprehensive step-by-step instructions for installation. If you are still having
problems, review the "Help!" section earlier in this hour. The online resources
mentioned there will almost certainly contain the answers you need.
Workshop
The Workshop provides quiz questions to help you solidify your understanding of the
material covered. Try to understand the quiz answers before continuing to the next
hour's lesson. Quiz answers are provided in Appendix A.

Quiz


Where can you find the PHP online manual?
From a UNIX operating system, how would you get help on configuration options
(the options that you pass to the configure script in your PHP distribution)?
What is Apache's configuration file typically called?
What line should you add to the Apache configuration file to ensure that the .php
extension is recognized?
What is PHP's configuration file called?
Activity
Install PHP on your system. If it is already in place, review your php.ini file and
check your configuration.

0 comments: