wwwroth
wwwroth

Reputation: 434

How to structure classes with frontend and backend (PHP)

I have a question about how to structure classes. Lately I've been working on changing my PHP coding style over to newer standards since although I'm employed and do a lot of PHP coding for web apps, I'm starting to notice the way I code is rather old and frowned upon. Here's a question. If I have a small blog section on my website and have one class for blog (clsBlog.php) that does all the lifting to build my blog on the frontend, do I also store methods to upload the blog from the backend inside that class? I've usually just created a class called clsAdmin.php and had all the methods that the admin utility uses.

Upvotes: 1

Views: 1742

Answers (1)

tereško
tereško

Reputation: 58444

You could have given us some examples of your current style. That would have let people to at least gage your current skill level.

I assume that the "frowned upon" style of programming, that you mentioned, can be described as "include based programming". Since I have never really used it, I cannot give you a clean & tested recipe for advancing.

The best I can offer you would be the list of links at the end of this answer. I would recommend to begin with "PHP Object-Oriented Solutions" book. Though, if you also have problems with newer PHP syntax, you might benefit from quickly skipping through "Beginning PHP 5.3".

Also, another thing you might look into might be the newer SQL API. There has begun a deprecation process for the ancient mysql_* functions. You should look into some alternatives. If you decide to go with PDO, then I would urge you to check this tutorial.

Upvotes: 1

Related Questions