1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

Working with someone else's code


Often it is easier to work with a preexisting PHP program than to sit down and write your own from scratch. Sometimes these programs come close to doing what you want, but don't do exactly what you want. In these cases you may want to go into the existing code and modify it for your needs. When doing this, here are some things to keep in mind.
Difficulty: Easy
Time Required: Varies

Here's How:

  1. Look at the license of the program. Does it allow you to make changes for your own use? Does it allow you to distribute the changes once they are made? Are you allowed to use the program for personal or commercial use? Never work with someone else's code if you don't have permission to do so!
  2. Always keep a backup of the original files! We all have "broke" programs at some point in time. Make sure you keep a copy of all the original files on hand for when this inevitably happens to you, so you can successfully backtrack and see where you went wrong.
  3. Leave lots of comments! If you leave notes to yourself or other programmers about what and why you have changed the original code, it makes future edits and easier.
  4. Give the original author credit. Whether you plan to redistribute the code with your changes, or you're just running it on your personal website, make sure all author lines are left intact. By all means add your own information as well, but always continue to give credit to the original author.
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Advanced PHP
  5. Editing pre-made code - Working with someone else's PHP

©2014 About.com. All rights reserved.