How to Cleanup a php.ini File

PHP

If like me, you hate programmer comments and like to keep your files super clean and straight to the point when you’re working on personal projects or projects only you manage and you also manage your PHP settings from a php.ini file, this how-to may be for you.

Using an advanced text editor like TextWrangler (for Mac) or Notepad++ (for Windows) we can do a lot of very powerful things, very quickly, with regex (regular expression — a search pattern language).

In many advanced text editors you can simply hit Command+F or Control+F and you’ll be able to do some find and replace operations. You should see an option to search by grep (a command-line tool to run regex), regex, or similar.

With php.ini open, run the following find and replace:

Find:

^\;.*$

Replace With:

leave blank

This will remove all comments from the file. Then, to cleanup all the empty space, run another regex:

Find:

^\s*

Replace With:

leave blank

That’s it. You’ll now have a super clean, easy to manage php.ini file.