Appendix B. Configuring PHP

This appendix assumes that you have the Web software installed.

PHP has many configuration settings that determine how it behaves. I talk about PHP settings at various places throughout the book. For instance, I talk about the PHP error settings when I explain how PHP errors work in Chapter 6. I explain the settings and when they need to be changed in context in the book.

The configuration settings are stored in a text file named php.ini. PHP looks for the file php.ini when it begins and uses the settings it finds. If PHP can't find the file, it uses a set of default settings.

All PHP settings can be changed in the php.ini file. Some settings should always be changed, and some should be changed only in specific circumstances. For example, magic quotes should always be turned off. I explain magic quotes in Chapter 6.

On your own computer, you always have access to the php.ini file and can change the settings yourself. However, a Web host isn't going to allow you access to the general php.ini file, because it controls the settings for all the users on the computer, not just for your site. So, you change any PHP settings on your Web hosting account with a different procedure:

  • A local php.ini file: Some Web hosts allow you to have a local php.ini file that controls: PHP's behavior for your Web site only. If so, you can make any needed changes in this local php.ini file.

  • An .htaccess file You can add directives to your .htaccess file that change PHP settings. Only ...

Get PHP and MySQL® For Dummies®, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.