How to use classes in php, part 1
Using classes is a major up for the developer becouse the code can be used in many projects, in many places into one project.
The code is more organized, the functions are found more easly when a debug is needed.
In this example we will build a class to validate some data that is submited in a form.
Don’t forget that this is an example, not more.
In the first place we need to declare the class:
<?php class validator { } ?>
This class is an empty class.the class doesn’t do anything.the functions from the class does all the job.
That’s what we will see in the next part.
When you use classes is a good ideea to keep the class in a single file(if is not that large) without any other functions or config variables, keep it simple.
In the next tutorial you will see how to create functions.