How/Why use PHP classes on a simple page [closed]
I want to create a simple PHP website containing quite a number of pages. The content of the pages will be editable by the admin(s) of the website using a simple online html text editor.
There should also be members, managed by the admin. (No self-registration)
There is also a members section with login.
Obviously this is not complicated to do procedurally, but I would like to try using classes.
Why should I even use PHP classes in this case? And where would they be useful? Or is there no good reason to use them for such a site?
Thanks
Using OOP principles even in small projects can help you fully understand the benefits of such Programming principles. Although the problem may be easy to solve procedural, it would be an extension and maintenance nightmare.
So:
- Think about your classes and their relations before coding (Maybe even draw some UML charts)
- Have a look at various design patterns, maybe one fits your problem here
- Stick to your design while coding ;)
To use classes makes sense if it is easier to use a class than to do something without (and for reusability if needed). Sure you could go without classes, but for example for your user management (your members) there are some helpfull classes to use.
精彩评论