I call it "Compartmentalization", that is, taking a long .php file and breaking it down into smaller components; Seperate .php files.

This will keep everything tidier, cleaner, more organized, reusable and I believe, more secure.

Example (Not my code - Maybe not a perfect example of this idea, but for illustration sake):


$server = "";
$dbuser = "";
$dbpass = "";
$database = "";


What is this called?

Can anyone direct me to an online resource detailing this? Best practices. I need to do this and I need to do it correctly.

Thank you in advance!

4 Years
Discussion Span
Last Post by pritaeas

I just viewed your link on the OO approach. Very nice and educational.

I am trying to envision how this would work with my project. Not sure yet.

Although I am having some issues with the coding, the project is not as large on the back-end as people may assume. I will be storing much data, but the actual processing is simple.

One of my main concerns is security (A topic for a later time).

I will have to keep in mind your fine example of the keycard/lock. How does this relate to this project? (Rhetorical)

I believe this approach may be good when handling the registration of new Users, a process more complex than people think. Plus, I'm building my own, advanced Captcha system, so the OO approach may work there great. Also, I'm designing a security-bot; More on that in the future.

Thank you for your help!


If you do not want to go OOP just yet, you can divide your code into logical functions and separate them into include files. Basically that's the first step, whether you use functions or classes.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.