Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

Cross-Platform Code 4: Coping with php.ini Differences

If you have made a lot of changes to your php.ini file, or indeed any changes from the default php.ini file, it is possible that scripts you write will not work elsewhere. There are three common culprits: extensions, register_globals, and safe mode.

If you have enabled an extension that isn't enabled in someone else's php.ini file, people deploying your script will get lots of errors about undefined functions. The best way around this, other than adding warnings about required extensions in your readme file, is to have a checkconfig.php file that runs checks on the current configuration to make sure it has the correct extensions available.

Register_globals is a setting that, when enabled, makes PHP put all user-submitted variables into the global scope automatically—not very secure, as you can imagine. The problem is that this setting was enabled by default in old versions of PHP 4, which means that a lot of people still have this setting enabled. If someone gives you a script that requires register_globals being enabled, it is probably best that you don't use it—it's just not worth the security risk. Similarly, you should avoid writing scripts that rely on register_globals, even if you choose to enable it locally—most people out there leave it disabled, as recommended.

The third problem you are likely to encounter when people use your scripts elsewhere is safe mode. With safe mode enabled, there is very little you can do to ensure ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page